home *** CD-ROM | disk | FTP | other *** search
/ Hot Super Models / Hot Super Models.iso / unix / x11 / xv200.tar / xv-2.00 / unsupt / VMS / XV.DIFF < prev   
Text File  |  1992-01-01  |  81KB  |  3,078 lines

  1. *** disk$vis:[xv.orig]bggen.c
  2. --- bggen.c
  3. **************
  4. *** 29,34
  5.   #define DEFSIZE 1024
  6.   #define MAXCOLS  128
  7.   
  8.   struct color { int r,g,b; int y; } cols[MAXCOLS], *cur, *nex;
  9.   
  10.   int bmask[8] = { 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff };
  11. --- 29,37 -----
  12.   #define DEFSIZE 1024
  13.   #define MAXCOLS  128
  14.   
  15. + #ifdef VMS
  16. + struct color { int r,g,b; int y; } colors[MAXCOLS], *cur, *nex;
  17. + #else
  18.   struct color { int r,g,b; int y; } cols[MAXCOLS], *cur, *nex;
  19.   #endif
  20.   
  21. **************
  22. *** 30,35
  23.   #define MAXCOLS  128
  24.   
  25.   struct color { int r,g,b; int y; } cols[MAXCOLS], *cur, *nex;
  26.   
  27.   int bmask[8] = { 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff };
  28.   
  29. --- 33,39 -----
  30.   struct color { int r,g,b; int y; } colors[MAXCOLS], *cur, *nex;
  31.   #else
  32.   struct color { int r,g,b; int y; } cols[MAXCOLS], *cur, *nex;
  33. + #endif
  34.   
  35.   int bmask[8] = { 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff };
  36.   
  37. **************
  38. *** 44,49
  39.     int bits = 8;
  40.     int r, g, b;
  41.   
  42.     cnt = 0;  numcols = 0;
  43.     for (i=1; i<argc; i++) {
  44.       if (!strcmp(argv[i],"-s")) high = atoi(argv[++i]);
  45. --- 48,56 -----
  46.     int bits = 8;
  47.     int r, g, b;
  48.   
  49. + #ifdef VMS
  50. +   getredirection (&argc, &argv);
  51. + #endif
  52.     cnt = 0;  numcols = 0;
  53.     for (i=1; i<argc; i++) {
  54.       if (!strcmp(argv[i],"-s")) high = atoi(argv[++i]);
  55. **************
  56. *** 56,61
  57.   
  58.       else {
  59.         switch (cnt) {
  60.         case 0:  cols[numcols].r = atoi(argv[i]);  break;
  61.         case 1:  cols[numcols].g = atoi(argv[i]);  break;
  62.         case 2:  cols[numcols].b = atoi(argv[i]);  break;
  63. --- 63,73 -----
  64.   
  65.       else {
  66.         switch (cnt) {
  67. + #ifdef VMS
  68. +       case 0:  colors[numcols].r = atoi(argv[i]);  break;
  69. +       case 1:  colors[numcols].g = atoi(argv[i]);  break;
  70. +       case 2:  colors[numcols].b = atoi(argv[i]);  break;
  71. + #else
  72.         case 0:  cols[numcols].r = atoi(argv[i]);  break;
  73.         case 1:  cols[numcols].g = atoi(argv[i]);  break;
  74.         case 2:  cols[numcols].b = atoi(argv[i]);  break;
  75. **************
  76. *** 59,64
  77.         case 0:  cols[numcols].r = atoi(argv[i]);  break;
  78.         case 1:  cols[numcols].g = atoi(argv[i]);  break;
  79.         case 2:  cols[numcols].b = atoi(argv[i]);  break;
  80.         }
  81.         cnt++;
  82.   
  83. --- 71,77 -----
  84.         case 0:  cols[numcols].r = atoi(argv[i]);  break;
  85.         case 1:  cols[numcols].g = atoi(argv[i]);  break;
  86.         case 2:  cols[numcols].b = atoi(argv[i]);  break;
  87. + #endif
  88.         }
  89.         cnt++;
  90.   
  91. **************
  92. *** 89,94
  93.     if (numcols==1) {
  94.       for (i=0; i<high; i++) 
  95.         for (j=0; j<wide; j++)
  96.       printf("%d %d %d\n",cols[0].r,cols[0].g,cols[0].b);
  97.     }
  98.     else {
  99. --- 102,110 -----
  100.     if (numcols==1) {
  101.       for (i=0; i<high; i++) 
  102.         for (j=0; j<wide; j++)
  103. + #ifdef VMS
  104. +     printf("%d %d %d\n",colors[0].r,colors[0].g,colors[0].b);
  105. + #else
  106.       printf("%d %d %d\n",cols[0].r,cols[0].g,cols[0].b);
  107.   #endif
  108.     }
  109. **************
  110. *** 90,95
  111.       for (i=0; i<high; i++) 
  112.         for (j=0; j<wide; j++)
  113.       printf("%d %d %d\n",cols[0].r,cols[0].g,cols[0].b);
  114.     }
  115.     else {
  116.   
  117. --- 106,112 -----
  118.       printf("%d %d %d\n",colors[0].r,colors[0].g,colors[0].b);
  119.   #else
  120.       printf("%d %d %d\n",cols[0].r,cols[0].g,cols[0].b);
  121. + #endif
  122.     }
  123.     else {
  124.   
  125. **************
  126. *** 95,100
  127.   
  128.       /* fill in 'y' field of cols[] */
  129.       for (i=0; i<numcols; i++)
  130.         cols[i].y = ((high-1) * i) / (numcols-1);
  131.   
  132.       cur = &cols[0];  nex = cur+1;
  133. --- 112,120 -----
  134.   
  135.       /* fill in 'y' field of cols[] */
  136.       for (i=0; i<numcols; i++)
  137. + #ifdef VMS
  138. +       colors[i].y = ((high-1) * i) / (numcols-1);
  139. + #else
  140.         cols[i].y = ((high-1) * i) / (numcols-1);
  141.   #endif
  142.   
  143. **************
  144. *** 96,101
  145.       /* fill in 'y' field of cols[] */
  146.       for (i=0; i<numcols; i++)
  147.         cols[i].y = ((high-1) * i) / (numcols-1);
  148.   
  149.       cur = &cols[0];  nex = cur+1;
  150.   
  151. --- 116,122 -----
  152.         colors[i].y = ((high-1) * i) / (numcols-1);
  153.   #else
  154.         cols[i].y = ((high-1) * i) / (numcols-1);
  155. + #endif
  156.   
  157.   #ifdef VMS
  158.       cur = &colors[0];  nex = cur+1;
  159. **************
  160. *** 97,102
  161.       for (i=0; i<numcols; i++)
  162.         cols[i].y = ((high-1) * i) / (numcols-1);
  163.   
  164.       cur = &cols[0];  nex = cur+1;
  165.   
  166.       for (i=0; i<high; i++) {
  167. --- 118,126 -----
  168.         cols[i].y = ((high-1) * i) / (numcols-1);
  169.   #endif
  170.   
  171. + #ifdef VMS
  172. +     cur = &colors[0];  nex = cur+1;
  173. + #else
  174.       cur = &cols[0];  nex = cur+1;
  175.   #endif
  176.   
  177. **************
  178. *** 98,103
  179.         cols[i].y = ((high-1) * i) / (numcols-1);
  180.   
  181.       cur = &cols[0];  nex = cur+1;
  182.   
  183.       for (i=0; i<high; i++) {
  184.         /* advance to next pair of colors if we're outside region */
  185. --- 122,128 -----
  186.       cur = &colors[0];  nex = cur+1;
  187.   #else
  188.       cur = &cols[0];  nex = cur+1;
  189. + #endif
  190.   
  191.       for (i=0; i<high; i++) {
  192.         /* advance to next pair of colors if we're outside region */
  193. *** disk$vis:[xv.orig]imakefile.
  194. --- imakefile.
  195. **************
  196. *** 75,81
  197.   
  198.   
  199.   #if defined(SCOArchitecture)
  200. ! DEFINES= -DPOSIX -DNOITIMER
  201.   SYS_LIBRARIES=        $(XLIB) -lm -lc -lx
  202.   #else
  203.   SYS_LIBRARIES=        $(XLIB) -lm
  204. --- 75,81 -----
  205.   
  206.   
  207.   #if defined(SCOArchitecture)
  208. ! SCO_DEFINES= -DPOSIX -DNOITIMER
  209.   SYS_LIBRARIES=        $(XLIB) -lm -lc -lx
  210.   #else
  211.   SYS_LIBRARIES=        $(XLIB) -lm
  212. **************
  213. *** 81,88
  214.   SYS_LIBRARIES=        $(XLIB) -lm
  215.   #endif
  216.   
  217. ! DEFINES= $(DEFINES) $(UNIX) $(NEED_DIRENT) $(BROKECOLS) \
  218. !      $(VPRINTF) $(TIMERS) $(ATT) $(USEMEM)
  219.   
  220.   SYS_LIBRARIES=    -lX11 -lm
  221.   
  222. --- 81,87 -----
  223.   SYS_LIBRARIES=        $(XLIB) -lm
  224.   #endif
  225.   
  226. ! JPEGDIR = $(HOME)/jpeg
  227.   
  228.   INCLUDES= -I$(JPEGDIR)
  229.   
  230. **************
  231. *** 84,89
  232.   DEFINES= $(DEFINES) $(UNIX) $(NEED_DIRENT) $(BROKECOLS) \
  233.        $(VPRINTF) $(TIMERS) $(ATT) $(USEMEM)
  234.   
  235.   SYS_LIBRARIES=    -lX11 -lm
  236.   
  237.   BITMAPS = bitmaps/grasp bitmaps/penn bitmaps/down bitmaps/down1 \
  238. --- 83,93 -----
  239.   
  240.   JPEGDIR = $(HOME)/jpeg
  241.   
  242. + INCLUDES= -I$(JPEGDIR)
  243. + DEFINES= $(SCO_DEFINES) $(UNIX) $(NEED_DIRENT) $(BROKECOLS) \
  244. +      $(VPRINTF) $(TIMERS) $(ATT) $(USEMEM)
  245.   SYS_LIBRARIES=    -lX11 -lm
  246.   
  247.   BITMAPS = bitmaps/grasp bitmaps/penn bitmaps/down bitmaps/down1 \
  248. **************
  249. *** 96,101
  250.             bitmaps/fc_left1m bitmaps/fc_right1 bitmaps/fc_right1m \
  251.         bitmaps/icon
  252.   
  253.   SRCS1 =    xv.c xv24to8.c xvbutt.c xvctrl.c xvdir.c xvfish.c xvgam.c\
  254.       xvgif.c xvgifwr.c xvinfo.c xvmisc.c xvpbm.c xvpm.c xvscrl.c\
  255.       xvxbm.c vprintf.c
  256. --- 100,111 -----
  257.             bitmaps/fc_left1m bitmaps/fc_right1 bitmaps/fc_right1m \
  258.         bitmaps/icon
  259.   
  260. + JOBJS =    $(JPEGDIR)/jerror.o $(JPEGDIR)/jrdjfif.o $(JPEGDIR)/jdcolor.o \
  261. +     $(JPEGDIR)/jdhuff.o $(JPEGDIR)/jdmaster.o $(JPEGDIR)/jdmcu.o \
  262. +     $(JPEGDIR)/jdpipe.o $(JPEGDIR)/jdsample.o $(JPEGDIR)/jrevdct.o \
  263. +     $(JPEGDIR)/jutils.o $(JPEGDIR)/jvirtmem.o $(JPEGDIR)/jbsmooth.o \
  264. +     $(JPEGDIR)/jquant1.o $(JPEGDIR)/jquant2.o
  265.   SRCS1 =    xv.c xv24to8.c xvbutt.c xvctrl.c xvdir.c xvfish.c xvgam.c\
  266.       xvgif.c xvgifwr.c xvinfo.c xvmisc.c xvpbm.c xvpm.c xvscrl.c\
  267.       xvxbm.c vprintf.c xvjpeg.c
  268. **************
  269. *** 98,104
  270.   
  271.   SRCS1 =    xv.c xv24to8.c xvbutt.c xvctrl.c xvdir.c xvfish.c xvgam.c\
  272.       xvgif.c xvgifwr.c xvinfo.c xvmisc.c xvpbm.c xvpm.c xvscrl.c\
  273. !     xvxbm.c vprintf.c
  274.   
  275.   OBJS1 =    xv.o xv24to8.o xvbutt.o xvctrl.o xvdir.o xvfish.o xvgam.o\
  276.       xvgif.o xvgifwr.o xvinfo.o xvmisc.o xvpbm.o xvpm.o xvscrl.o \
  277. --- 108,114 -----
  278.   
  279.   SRCS1 =    xv.c xv24to8.c xvbutt.c xvctrl.c xvdir.c xvfish.c xvgam.c\
  280.       xvgif.c xvgifwr.c xvinfo.c xvmisc.c xvpbm.c xvpm.c xvscrl.c\
  281. !     xvxbm.c vprintf.c xvjpeg.c
  282.   
  283.   OBJS1 =    xv.o xv24to8.o xvbutt.o xvctrl.o xvdir.o xvfish.o xvgam.o\
  284.       xvgif.o xvgifwr.o xvinfo.o xvmisc.o xvpbm.o xvpm.o xvscrl.o \
  285. **************
  286. *** 102,108
  287.   
  288.   OBJS1 =    xv.o xv24to8.o xvbutt.o xvctrl.o xvdir.o xvfish.o xvgam.o\
  289.       xvgif.o xvgifwr.o xvinfo.o xvmisc.o xvpbm.o xvpm.o xvscrl.o \
  290. !     xvxbm.o vprintf.o
  291.   
  292.   SRCS2=    bggen.c
  293.   OBJS2=    bggen.o
  294. --- 112,118 -----
  295.   
  296.   OBJS1 =    xv.o xv24to8.o xvbutt.o xvctrl.o xvdir.o xvfish.o xvgam.o\
  297.       xvgif.o xvgifwr.o xvinfo.o xvmisc.o xvpbm.o xvpm.o xvscrl.o \
  298. !     xvxbm.o vprintf.o xvjpeg.o $(JOBJS)
  299.   
  300.   SRCS2=    bggen.c
  301.   OBJS2=    bggen.o
  302. **************
  303. *** 109,114
  304.   
  305.   PROGRAMS= xv bggen
  306.   
  307.   ComplexProgramTarget_1(xv,,)
  308.   ComplexProgramTarget_2(bggen,,)
  309.   
  310. --- 119,128 -----
  311.   
  312.   PROGRAMS= xv bggen
  313.   
  314. + #define IHaveSubdirs
  315. + #define PassCDebugFlags
  316. + SUBDIRS= $(JPEGDIR)
  317. + MakeSubdirs($(SUBDIRS))
  318.   ComplexProgramTarget_1(xv,,)
  319.   ComplexProgramTarget_2(bggen,,)
  320.   
  321. *** disk$vis:[xv.orig]xv.c
  322. --- xv.c
  323. **************
  324. *** 53,58
  325.   #define PM      2
  326.   #define PBM     3
  327.   #define XBM     4
  328.   
  329.   static unsigned long rootbg, rootfg;  /* fg/bg for root border */
  330.   static int    waitsec = -1;     /* seconds between pics. -1=wait for event */
  331. --- 53,59 -----
  332.   #define PM      2
  333.   #define PBM     3
  334.   #define XBM     4
  335. + #define JFIF    5
  336.   
  337.   static unsigned long rootbg, rootfg;  /* fg/bg for root border */
  338.   static int    waitsec = -1;     /* seconds between pics. -1=wait for event */
  339. **************
  340. *** 97,102
  341.   static int  rd_int();
  342.   static int  rd_str();
  343.   static int  rd_flag();
  344.   
  345.   
  346.   
  347. --- 98,105 -----
  348.   static int  rd_int();
  349.   static int  rd_str();
  350.   static int  rd_flag();
  351. + static int  XvErrorHandler();
  352. + static int  rd_boolean();
  353.   
  354.   
  355.   
  356. **************
  357. *** 121,127
  358.     /*** variable Initialization                       ***/
  359.     /*****************************************************/
  360.   
  361. ! #ifdef SYSV
  362.     getcwd(initpath, sizeof(initpath));
  363.   #else
  364.     getwd(initpath);
  365. --- 124,130 -----
  366.     /*** variable Initialization                       ***/
  367.     /*****************************************************/
  368.   
  369. ! #if (defined(SYSV) || defined(SVR4) || defined(VMS))
  370.     getcwd(initpath, sizeof(initpath));
  371.   #else
  372.     getwd(initpath);
  373. **************
  374. *** 134,139
  375.     theImage = NULL;
  376.     LocalCmap = 0;
  377.     InitFSDTables();
  378.     cmd = rindex(argv[0],'/');
  379.     if (!cmd) cmd = argv[0]; else cmd++;
  380.   
  381. --- 137,146 -----
  382.     theImage = NULL;
  383.     LocalCmap = 0;
  384.     InitFSDTables();
  385. + #ifdef VMS
  386. +   getredirection (&argc, &argv);
  387. +   cmd = rindex(argv[0],']');
  388. + #else
  389.     cmd = rindex(argv[0],'/');
  390.   #endif
  391.     if (!cmd) cmd = argv[0]; else cmd++;
  392. **************
  393. *** 135,140
  394.     LocalCmap = 0;
  395.     InitFSDTables();
  396.     cmd = rindex(argv[0],'/');
  397.     if (!cmd) cmd = argv[0]; else cmd++;
  398.   
  399.   
  400. --- 142,148 -----
  401.     cmd = rindex(argv[0],']');
  402.   #else
  403.     cmd = rindex(argv[0],'/');
  404. + #endif
  405.     if (!cmd) cmd = argv[0]; else cmd++;
  406.   
  407.   
  408. **************
  409. *** 158,169
  410.     useroot = clrroot = noqcheck = rwcolor = fishrunning = 0;
  411.     fish = 0;
  412.   
  413. - #ifdef BROKEFREECOLS
  414. -   brokeFreeCols = 1;
  415. - #else
  416. -   brokeFreeCols = 0;
  417. - #endif
  418.     defaspect = normaspect = 1.0;
  419.   
  420.     mainW = dirW = infoW = ctrlW = gamW = NULL;
  421. --- 166,171 -----
  422.     useroot = clrroot = noqcheck = rwcolor = fishrunning = 0;
  423.     fish = 0;
  424.   
  425.     defaspect = normaspect = 1.0;
  426.   
  427.     mainW = dirW = infoW = ctrlW = gamW = NULL;
  428. **************
  429. *** 210,216
  430.     if (rd_str ("background"))    bgstr       = def_str;
  431.     if (rd_str ("black"))         blackstr    = def_str;
  432.     if (rd_int ("borderWidth"))   bwidth      = def_int;
  433. -   if (rd_flag("brokeFreeCols")) brokeFreeCols = def_int;
  434.     if (rd_flag("centerPic"))     centerpic   = def_int;
  435.     if (rd_str ("ctrlGeometry"))  ctrlgeom    = def_str;
  436.     if (rd_flag("ctrlMap"))       ctrlmap     = def_int;
  437. --- 212,217 -----
  438.     if (rd_str ("background"))    bgstr       = def_str;
  439.     if (rd_str ("black"))         blackstr    = def_str;
  440.     if (rd_int ("borderWidth"))   bwidth      = def_int;
  441.     if (rd_flag("centerPic"))     centerpic   = def_int;
  442.     if (rd_str ("ctrlGeometry"))  ctrlgeom    = def_str;
  443.     if (rd_flag("ctrlMap"))       ctrlmap     = def_int;
  444. **************
  445. *** 294,302
  446.       else if (!strncmp(argv[i],"-au",3))  /* autogamma */
  447.         autogamma++;
  448.   
  449. -     else if (!strncmp(argv[i],"-bf",3))  /* brokeFreeCols */
  450. -       brokeFreeCols = !brokeFreeCols;
  451.       else if (!strncmp(argv[i],"-bg",3)) /* background color */
  452.         { if (++i<argc) bgstr = argv[i]; }
  453.   
  454. --- 295,300 -----
  455.       else if (!strncmp(argv[i],"-au",3))  /* autogamma */
  456.         autogamma++;
  457.   
  458.       else if (!strncmp(argv[i],"-bg",3)) /* background color */
  459.         { if (++i<argc) bgstr = argv[i]; }
  460.   
  461. **************
  462. *** 711,716
  463.     /* set up fullname and basename */
  464.   
  465.     fullname = namelist[filenum];
  466.     tmp = rindex(fullname,'/');
  467.     if (!tmp) tmp = fullname; else tmp++;
  468.     strcpy(basename,tmp);
  469. --- 709,717 -----
  470.     /* set up fullname and basename */
  471.   
  472.     fullname = namelist[filenum];
  473. + #ifdef VMS
  474. +   tmp = rindex(fullname,']');
  475. + #else
  476.     tmp = rindex(fullname,'/');
  477.   #endif
  478.     if (!tmp) tmp = fullname; else tmp++;
  479. **************
  480. *** 712,717
  481.   
  482.     fullname = namelist[filenum];
  483.     tmp = rindex(fullname,'/');
  484.     if (!tmp) tmp = fullname; else tmp++;
  485.     strcpy(basename,tmp);
  486.     if (strlen(basename)>2 && strcmp(basename+strlen(basename)-2,".Z")==0) 
  487. --- 713,719 -----
  488.     tmp = rindex(fullname,']');
  489.   #else
  490.     tmp = rindex(fullname,'/');
  491. + #endif
  492.     if (!tmp) tmp = fullname; else tmp++;
  493.     strcpy(basename,tmp);
  494.     if (strlen(basename)>2 && strcmp(basename+strlen(basename)-2,".Z")==0) 
  495. **************
  496. *** 722,727
  497.     freename = 0;
  498.     if (fullname[0] != '/' && strcmp(fullname,STDINSTR)!=0) {
  499.       char *tmp;
  500.       tmp = (char *) malloc(strlen(fullname) + strlen(initpath) + 2);
  501.       if (!tmp) FatalError("malloc 'filename' failed");
  502.       sprintf(tmp,"%s/%s", initpath, fullname);
  503. --- 724,732 -----
  504.     freename = 0;
  505.     if (fullname[0] != '/' && strcmp(fullname,STDINSTR)!=0) {
  506.       char *tmp;
  507. + #ifdef VMS
  508. +     tmp = (char *) malloc(strlen(fullname) + 2);
  509. + #else
  510.       tmp = (char *) malloc(strlen(fullname) + strlen(initpath) + 2);
  511.   #endif
  512.       if (!tmp) FatalError("malloc 'filename' failed");
  513. **************
  514. *** 723,728
  515.     if (fullname[0] != '/' && strcmp(fullname,STDINSTR)!=0) {
  516.       char *tmp;
  517.       tmp = (char *) malloc(strlen(fullname) + strlen(initpath) + 2);
  518.       if (!tmp) FatalError("malloc 'filename' failed");
  519.       sprintf(tmp,"%s/%s", initpath, fullname);
  520.       fullname = tmp;
  521. --- 728,734 -----
  522.       tmp = (char *) malloc(strlen(fullname) + 2);
  523.   #else
  524.       tmp = (char *) malloc(strlen(fullname) + strlen(initpath) + 2);
  525. + #endif
  526.       if (!tmp) FatalError("malloc 'filename' failed");
  527.   #ifdef VMS
  528.       sprintf(tmp,"%s", fullname);
  529. **************
  530. *** 724,729
  531.       char *tmp;
  532.       tmp = (char *) malloc(strlen(fullname) + strlen(initpath) + 2);
  533.       if (!tmp) FatalError("malloc 'filename' failed");
  534.       sprintf(tmp,"%s/%s", initpath, fullname);
  535.       fullname = tmp;
  536.       freename = 1;
  537. --- 730,738 -----
  538.       tmp = (char *) malloc(strlen(fullname) + strlen(initpath) + 2);
  539.   #endif
  540.       if (!tmp) FatalError("malloc 'filename' failed");
  541. + #ifdef VMS
  542. +     sprintf(tmp,"%s", fullname);
  543. + #else
  544.       sprintf(tmp,"%s/%s", initpath, fullname);
  545.   #endif
  546.       fullname = tmp;
  547. **************
  548. *** 725,730
  549.       tmp = (char *) malloc(strlen(fullname) + strlen(initpath) + 2);
  550.       if (!tmp) FatalError("malloc 'filename' failed");
  551.       sprintf(tmp,"%s/%s", initpath, fullname);
  552.       fullname = tmp;
  553.       freename = 1;
  554.     }
  555. --- 734,740 -----
  556.       sprintf(tmp,"%s", fullname);
  557.   #else
  558.       sprintf(tmp,"%s/%s", initpath, fullname);
  559. + #endif
  560.       fullname = tmp;
  561.       freename = 1;
  562.     }
  563. **************
  564. *** 752,757
  565.     if (strcmp(filename,STDINSTR)==0) {
  566.       FILE *fp;
  567.   
  568.       strcpy(filename,"/tmp/xvXXXXXX");
  569.       mktemp(filename);
  570.   
  571. --- 762,770 -----
  572.     if (strcmp(filename,STDINSTR)==0) {
  573.       FILE *fp;
  574.   
  575. + #ifdef VMS
  576. +     strcpy(filename,"Sys$Disk:[]xvXXXXXX");
  577. + #else
  578.       strcpy(filename,"/tmp/xvXXXXXX");
  579.   #endif
  580.       mktemp(filename);
  581. **************
  582. *** 753,758
  583.       FILE *fp;
  584.   
  585.       strcpy(filename,"/tmp/xvXXXXXX");
  586.       mktemp(filename);
  587.   
  588.       fp = fopen(filename,"w");
  589. --- 766,772 -----
  590.       strcpy(filename,"Sys$Disk:[]xvXXXXXX");
  591.   #else
  592.       strcpy(filename,"/tmp/xvXXXXXX");
  593. + #endif
  594.       mktemp(filename);
  595.   
  596.       fp = fopen(filename,"w");
  597. **************
  598. *** 756,761
  599.       mktemp(filename);
  600.   
  601.       fp = fopen(filename,"w");
  602.       if (!fp) FatalError("can't write /tmp/xv****** file");
  603.       
  604.       while ( (i=getchar()) != EOF) putc(i,fp);
  605. --- 770,778 -----
  606.       mktemp(filename);
  607.   
  608.       fp = fopen(filename,"w");
  609. + #ifdef VMS
  610. +     if (!fp) FatalError("can't write Sys$Disk:[]xv****** file");
  611. + #else
  612.       if (!fp) FatalError("can't write /tmp/xv****** file");
  613.   #endif
  614.       
  615. **************
  616. *** 757,762
  617.   
  618.       fp = fopen(filename,"w");
  619.       if (!fp) FatalError("can't write /tmp/xv****** file");
  620.       
  621.       while ( (i=getchar()) != EOF) putc(i,fp);
  622.       fclose(fp);
  623. --- 774,780 -----
  624.       if (!fp) FatalError("can't write Sys$Disk:[]xv****** file");
  625.   #else
  626.       if (!fp) FatalError("can't write /tmp/xv****** file");
  627. + #endif
  628.       
  629.       while ( (i=getchar()) != EOF) putc(i,fp);
  630.       fclose(fp);
  631. **************
  632. *** 768,773
  633.   
  634.     fp=fopen(filename,"r");
  635.     if (!fp) {
  636.       SetISTR(ISTR_INFO,"Can't open '%s' -  %s",filename,sys_errlist[errno]);
  637.       Warning();
  638.       goto FAILED;
  639. --- 786,794 -----
  640.   
  641.     fp=fopen(filename,"r");
  642.     if (!fp) {
  643. + #ifdef VMS
  644. +     SetISTR(ISTR_INFO,"Can't open '%s'",filename);
  645. + #else
  646.       SetISTR(ISTR_INFO,"Can't open '%s' -  %s",filename,sys_errlist[errno]);
  647.   #endif
  648.       Warning();
  649. **************
  650. *** 769,774
  651.     fp=fopen(filename,"r");
  652.     if (!fp) {
  653.       SetISTR(ISTR_INFO,"Can't open '%s' -  %s",filename,sys_errlist[errno]);
  654.       Warning();
  655.       goto FAILED;
  656.     }
  657. --- 790,796 -----
  658.       SetISTR(ISTR_INFO,"Can't open '%s'",filename);
  659.   #else
  660.       SetISTR(ISTR_INFO,"Can't open '%s' -  %s",filename,sys_errlist[errno]);
  661. + #endif
  662.       Warning();
  663.       goto FAILED;
  664.     }
  665. **************
  666. *** 777,783
  667.     fclose(fp);
  668.   
  669.     filetype = UNKNOWN;
  670. !   if (strncmp(magicno,"GIF87",5)==0) filetype = GIF;
  671.   
  672.     else if (strncmp(magicno,"VIEW",4)==0 ||
  673.          strncmp(magicno,"WEIV",4)==0) filetype = PM;
  674. --- 799,805 -----
  675.     fclose(fp);
  676.   
  677.     filetype = UNKNOWN;
  678. !   if (strncmp(magicno,"GIF",3)==0) filetype = GIF;
  679.   
  680.     else if (magicno[0] == -1 && 
  681.          magicno[1] == -40 && 
  682. **************
  683. *** 779,784
  684.     filetype = UNKNOWN;
  685.     if (strncmp(magicno,"GIF87",5)==0) filetype = GIF;
  686.   
  687.     else if (strncmp(magicno,"VIEW",4)==0 ||
  688.          strncmp(magicno,"WEIV",4)==0) filetype = PM;
  689.   
  690. --- 801,810 -----
  691.     filetype = UNKNOWN;
  692.     if (strncmp(magicno,"GIF",3)==0) filetype = GIF;
  693.   
  694. +   else if (magicno[0] == -1 && 
  695. +        magicno[1] == -40 && 
  696. +        magicno[2] == -1) filetype = JFIF; 
  697.     else if (strncmp(magicno,"VIEW",4)==0 ||
  698.          strncmp(magicno,"WEIV",4)==0) filetype = PM;
  699.   
  700. **************
  701. *** 796,805
  702.     SetISTR(ISTR_INFO,"Loading '%s'...",basename);
  703.   
  704.     switch (filetype) {
  705. !   case GIF: i = LoadGIF(filename,ncols); break;
  706. !   case PM:  i = LoadPM (filename,ncols); break;
  707. !   case PBM: i = LoadPBM(filename,ncols); break;
  708. !   case XBM: i = LoadXBM(filename,ncols); break;
  709.     }
  710.     WaitCursor();
  711.   
  712. --- 822,834 -----
  713.     SetISTR(ISTR_INFO,"Loading '%s'...",basename);
  714.   
  715.     switch (filetype) {
  716. !   case GIF:  i = LoadGIF (filename,ncols); break;
  717. !   case PM:   i = LoadPM  (filename,ncols); break;
  718. !   case PBM:  i = LoadPBM (filename,ncols); break;
  719. !   case XBM:  i = LoadXBM (filename,ncols); break;
  720. ! /*  not avaiable yet
  721. !   case JFIF: i = LoadJFIF(filename,ncols); break;
  722. ! */
  723.     }
  724.     WaitCursor();
  725.   
  726. **************
  727. *** 960,969
  728.       XFreeColormap(theDisp,LocalCmap);
  729.       LocalCmap = 0;
  730.     }
  731. -   else if (!brokeFreeCols) {
  732. -     for (i=0; i<nfcols; i++) 
  733. -       XFreeColors(theDisp, theCmap, &freecols[i], 1, 0L);
  734. -   }
  735.     else {
  736.       for (i=0; i<nfcols; i++) {
  737.         int j;
  738. --- 989,994 -----
  739.       XFreeColormap(theDisp,LocalCmap);
  740.       LocalCmap = 0;
  741.     }
  742.     else {
  743.       XvFreeColors(theDisp, theCmap, freecols, 1, 0L, nfcols);
  744.     }
  745. **************
  746. *** 965,979
  747.         XFreeColors(theDisp, theCmap, &freecols[i], 1, 0L);
  748.     }
  749.     else {
  750. !     for (i=0; i<nfcols; i++) {
  751. !       int j;
  752. !       for (j=0; j<i; j++) {
  753. !         if (freecols[i] == freecols[j])   /* already been freed once */
  754. !       break;
  755. !       }
  756. !       if (j==i)      /* wasn't found in already-freed list */
  757. !         XFreeColors(theDisp, theCmap, &freecols[i], 1, 0L);
  758. !     }
  759.     }
  760.   
  761.     if (epic != cpic && epic != NULL) free(epic);
  762. --- 990,996 -----
  763.       LocalCmap = 0;
  764.     }
  765.     else {
  766. !     XvFreeColors(theDisp, theCmap, freecols, 1, 0L, nfcols);
  767.     }
  768.   
  769.     if (epic != cpic && epic != NULL) free(epic);
  770. **************
  771. *** 1791,1796
  772.      * twm where resize was giving 23 extra lines...
  773.      * should do no harm if this bug is not present.
  774.      */
  775.     XSync(theDisp,False);
  776.     XGetWindowAttributes(theDisp, mainW, &pxwa);
  777.     if (pxwa.height != xwa->height) {
  778. --- 1808,1814 -----
  779.      * twm where resize was giving 23 extra lines...
  780.      * should do no harm if this bug is not present.
  781.      */
  782. + #ifdef TWMKLUDGE
  783.     XSync(theDisp,False);
  784.     XGetWindowAttributes(theDisp, mainW, &pxwa);
  785.     if (pxwa.height != xwa->height) {
  786. **************
  787. *** 1803,1808
  788.       XResizeWindow(theDisp, mainW, xwa->width, 
  789.             xwa->height - (pxwa.height - xwa->height));
  790.     }
  791.   
  792.   }
  793.   
  794. --- 1821,1827 -----
  795.       XResizeWindow(theDisp, mainW, xwa->width, 
  796.             xwa->height - (pxwa.height - xwa->height));
  797.     }
  798. + #endif /* TWMKLUDGE */
  799.   
  800.   }
  801.   
  802. **************
  803. *** 2039,2044
  804.     /* returns true if there's a config event in which mainW changes size
  805.        in the event queue */
  806.   
  807.     foo = 0;
  808.     XCheckIfEvent(theDisp, &ev, IsConfig, &foo);
  809.     return foo;
  810. --- 2058,2064 -----
  811.     /* returns true if there's a config event in which mainW changes size
  812.        in the event queue */
  813.   
  814. +   XSync(theDisp, False);
  815.     foo = 0;
  816.     XCheckIfEvent(theDisp, &ev, IsConfig, &foo);
  817.     return foo;
  818. **************
  819. *** 2224,2233
  820.     /* returns '1' if successful.  result in def_str */
  821.     
  822.     if (def_str = XGetDefault(theDisp, PROGNAME, name)) {
  823. !     def_int = (strcmp(def_str, "on")==0) || 
  824. !               (strcmp(def_str, "1")==0) ||
  825. !           (strcmp(def_str, "true")==0) ||
  826. !           (strcmp(def_str, "yes")==0);
  827.       return 1;
  828.       }
  829.   
  830. --- 2244,2250 -----
  831.     /* returns '1' if successful.  result in def_str */
  832.     
  833.     if (def_str = XGetDefault(theDisp, PROGNAME, name)) {
  834. !     def_int = rd_boolean(def_str);
  835.       return 1;
  836.       }
  837.   
  838. **************
  839. *** 2234,2239
  840.     else return 0;
  841.   }
  842.       
  843.   
  844.   
  845.   
  846. --- 2251,2335 -----
  847.     else return 0;
  848.   }
  849.       
  850. + void XvFreeColors(display, colormap, pixels, npixels, planes, nfcols)
  851. +   Display       * display;
  852. +   Colormap        colormap;
  853. +   unsigned long * pixels;
  854. +   int             npixels;
  855. +   unsigned long   planes;
  856. +   int             nfcols;
  857. + {
  858. +   int i;
  859. +   XSetErrorHandler(XvErrorHandler); /* Handle X_FreeColors error messages */
  860. +   for (i=0; i<nfcols; i++) 
  861. +     XFreeColors(display, colormap, &pixels[i], npixels, planes);
  862. +   XSync(theDisp, False); /* Sync the display so that there won't be */
  863. +   XSetErrorHandler(0);   /* problems restoring the default error handler */
  864. + }
  865. + static int XvErrorHandler(display, err)
  866. + Display *display;
  867. + XErrorEvent *err;
  868. + {
  869. +   /* 
  870. +    * What should be done here?  Probably a check for request code 88
  871. +    * And a call to the default error handle under all other errors
  872. +    */
  873. + }  
  874. +   
  875. + /***********************************/
  876. + static int rd_boolean(value)
  877. + char *value;
  878. + {
  879. +   int   i;
  880. +   int   match;
  881. +  
  882. + #define MAXKEYWORDLEN   4  /* the strlen() of largest element in keywords[] */
  883. +  
  884. +   char  tmp[MAXKEYWORDLEN + 1];
  885. +   char *ptr;
  886. +   static char *keywords[] = {
  887. +     "1",
  888. +     "on",
  889. +     "yes",
  890. +     "true",
  891. +     (char *) 0
  892. +   };
  893. +  
  894. +   /* Will 'value' fit in 'tmp' */
  895. +   if (strlen(value) > MAXKEYWORDLEN)
  896. +   { /* Nope, must no be a valid value */
  897. +     return 0;
  898. +   }
  899. +   else
  900. +   { /* get a local copy of value */
  901. +     (void) strncpy(tmp, value, MAXKEYWORDLEN + 1);
  902. +   }
  903. +  
  904. +   /* convert the local copy to lower case */
  905. +   ptr = tmp;
  906. +   while (*ptr != '\0')
  907. +   {
  908. +     *ptr = isupper(*ptr) ? tolower(*ptr) : *ptr;
  909. +     ptr++;
  910. +   }
  911. +   /* search the array of keywords for a match */
  912. +   i = 0;
  913. +   match = 0;
  914. +   while (keywords[i] != (char *) 0)
  915. +   {
  916. +     if (strcmp(tmp, keywords[i]) == 0)
  917. +     {
  918. +       match = 1;
  919. +     }
  920. +     i++;
  921. +   }
  922. +   return(match);
  923. + }
  924. +   
  925.   
  926.   
  927.   
  928. *** disk$vis:[xv.orig]xv.h
  929. --- xv.h
  930. **************
  931. *** 30,35
  932.   #include <math.h>
  933.   #include <ctype.h>
  934.   #include <string.h>
  935.   extern int   errno;             /* this SHOULD be in errno.h */
  936.   extern char *sys_errlist[];     /* this SHOULD be in errno.h */
  937.   
  938. --- 30,38 -----
  939.   #include <math.h>
  940.   #include <ctype.h>
  941.   #include <string.h>
  942. + #ifdef VMS
  943. + #include <errno.h>
  944. + #else
  945.   extern int   errno;             /* this SHOULD be in errno.h */
  946.   extern char *sys_errlist[];     /* this SHOULD be in errno.h */
  947.   #endif
  948. **************
  949. *** 32,37
  950.   #include <string.h>
  951.   extern int   errno;             /* this SHOULD be in errno.h */
  952.   extern char *sys_errlist[];     /* this SHOULD be in errno.h */
  953.   
  954.   #ifndef __convexc__             /* Convex doesn't have <memory.h> */
  955.   #include <memory.h>             /* for 'memset()' prototype */
  956. --- 35,41 -----
  957.   #else
  958.   extern int   errno;             /* this SHOULD be in errno.h */
  959.   extern char *sys_errlist[];     /* this SHOULD be in errno.h */
  960. + #endif
  961.   
  962.   /* Convex and VMS doesn't have <memory.h> */
  963.   #if !(defined(__convexc__) || defined(VMS))
  964. **************
  965. *** 33,39
  966.   extern int   errno;             /* this SHOULD be in errno.h */
  967.   extern char *sys_errlist[];     /* this SHOULD be in errno.h */
  968.   
  969. ! #ifndef __convexc__             /* Convex doesn't have <memory.h> */
  970.   #include <memory.h>             /* for 'memset()' prototype */
  971.   #endif
  972.   
  973. --- 37,44 -----
  974.   extern char *sys_errlist[];     /* this SHOULD be in errno.h */
  975.   #endif
  976.   
  977. ! /* Convex and VMS doesn't have <memory.h> */
  978. ! #if !(defined(__convexc__) || defined(VMS))
  979.   #include <memory.h>             /* for 'memset()' prototype */
  980.   #endif
  981.   
  982. **************
  983. *** 38,45
  984.   #endif
  985.   
  986.   /* neither IBM AOS 4.3, Convex, nor BSD 4.3 on VAX have <malloc.h> */
  987. ! #if !defined(ibm032) && !defined(__convexc__) && \
  988. !     !(defined(vax) && !defined(ultrix))
  989.   #if defined(hp300) || defined(hp800)
  990.   #include <sys/malloc.h>                /* it's in 'sys' on HPs*/
  991.   #else
  992. --- 43,49 -----
  993.   #endif
  994.   
  995.   /* neither IBM AOS 4.3, Convex, nor BSD 4.3 on VAX have <malloc.h> */
  996. ! #if !defined(ibm032) && !defined(__convexc__) && !(defined(vax) && !defined(ultrix))
  997.   #if defined(hp300) || defined(hp800)
  998.   #include <sys/malloc.h>                /* it's in 'sys' on HPs*/
  999.   #else
  1000. **************
  1001. *** 52,57
  1002.   #define memcpy(d,s,l) bcopy(s,d,l)
  1003.   #endif
  1004.   
  1005.   
  1006.   #include <X11/Xos.h>
  1007.   #include <X11/Xlib.h>
  1008. --- 56,67 -----
  1009.   #define memcpy(d,s,l) bcopy(s,d,l)
  1010.   #endif
  1011.   
  1012. + #ifdef VMS
  1013. + #define bcopy(src,dst,len) memcpy(dst,src,len)
  1014. + #define unlink remove
  1015. + #define index(s,c) strchr(s,c)
  1016. + #define rindex(s,c) strrchr(s,c)
  1017. + #endif
  1018.   
  1019.   #include <X11/Xos.h>
  1020.   #include <X11/Xlib.h>
  1021. **************
  1022. *** 68,73
  1023.   #ifndef sgi              /* silicon graphics doesn't have timeb.h */
  1024.   #include <sys/timeb.h>
  1025.   #endif
  1026.   #include <signal.h>
  1027.   #if defined(sco) && !defined(NOTIMER)
  1028.   #include <sys/itimer.h>
  1029. --- 78,84 -----
  1030.   #ifndef sgi              /* silicon graphics doesn't have timeb.h */
  1031.   #include <sys/timeb.h>
  1032.   #endif
  1033. + #undef SIGCHLD
  1034.   #include <signal.h>
  1035.   #if defined(sco) && !defined(NOTIMER)
  1036.   #include <sys/itimer.h>
  1037. **************
  1038. *** 78,83
  1039.   #endif
  1040.   
  1041.   #ifdef NEEDSDIR
  1042.   #ifdef sco
  1043.   #include <sys/ndir.h>
  1044.   #define lstat stat
  1045. --- 89,95 -----
  1046.   #endif
  1047.   
  1048.   #ifdef NEEDSDIR
  1049. + #ifndef HPUX
  1050.   #ifdef sco
  1051.   #include <sys/ndir.h>
  1052.   #define lstat stat
  1053. **************
  1054. *** 86,91
  1055.   #include <sys/dir.h>
  1056.   #endif  /* ATT */
  1057.   #endif  /* sco */
  1058.   #include <sys/param.h>
  1059.   #include <sys/stat.h>
  1060.   #ifdef DIRENT
  1061. --- 98,105 -----
  1062.   #include <sys/dir.h>
  1063.   #endif  /* ATT */
  1064.   #endif  /* sco */
  1065. + #endif  /* not HPUX */
  1066. + #ifndef VMS
  1067.   #include <sys/param.h>
  1068.   #endif  /* not VMS */
  1069.   #include <sys/stat.h>
  1070. **************
  1071. *** 87,92
  1072.   #endif  /* ATT */
  1073.   #endif  /* sco */
  1074.   #include <sys/param.h>
  1075.   #include <sys/stat.h>
  1076.   #ifdef DIRENT
  1077.   #include <dirent.h>
  1078. --- 101,107 -----
  1079.   #endif  /* not HPUX */
  1080.   #ifndef VMS
  1081.   #include <sys/param.h>
  1082. + #endif  /* not VMS */
  1083.   #include <sys/stat.h>
  1084.   #ifdef DIRENT
  1085.   #ifdef VMS
  1086. **************
  1087. *** 89,94
  1088.   #include <sys/param.h>
  1089.   #include <sys/stat.h>
  1090.   #ifdef DIRENT
  1091.   #include <dirent.h>
  1092.   #endif
  1093.   #endif
  1094. --- 104,113 -----
  1095.   #endif  /* not VMS */
  1096.   #include <sys/stat.h>
  1097.   #ifdef DIRENT
  1098. + #ifdef VMS
  1099. + #include <descrip.h>
  1100. + #include "dirent.h"
  1101. + #else
  1102.   #include <dirent.h>
  1103.   #endif  /* VMS */
  1104.   #endif  /* DIRENT */
  1105. **************
  1106. *** 90,97
  1107.   #include <sys/stat.h>
  1108.   #ifdef DIRENT
  1109.   #include <dirent.h>
  1110. ! #endif
  1111. ! #endif
  1112.   
  1113.   #ifdef NEEDSVARARGS
  1114.   #include <varargs.h>
  1115. --- 109,117 -----
  1116.   #include "dirent.h"
  1117.   #else
  1118.   #include <dirent.h>
  1119. ! #endif  /* VMS */
  1120. ! #endif  /* DIRENT */
  1121. ! #endif  /* NEEDSDIR */
  1122.   
  1123.   #ifdef NEEDSVARARGS
  1124.   #include <varargs.h>
  1125. **************
  1126. *** 100,106
  1127.   /* signal macros */
  1128.   #ifdef SVR4
  1129.   #define HOLD_SIG         sighold(SIGALRM)  /* block ALRM sig from occurring */
  1130. ! #define RELEASE_SIG      sigrelse(SIGALRM) /* 
  1131.   #define PAUSE_SIG        sigpause(SIGALRM) /* sleep until ALRM signal */
  1132.   #else
  1133.   #define HOLD_SIG         sigblock(sigmask(SIGALRM))
  1134. --- 120,126 -----
  1135.   /* signal macros */
  1136.   #ifdef SVR4
  1137.   #define HOLD_SIG         sighold(SIGALRM)  /* block ALRM sig from occurring */
  1138. ! #define RELEASE_SIG      sigrelse(SIGALRM) /* */
  1139.   #define PAUSE_SIG        sigpause(SIGALRM) /* sleep until ALRM signal */
  1140.   #else
  1141.   #define HOLD_SIG         sigblock(sigmask(SIGALRM))
  1142. **************
  1143. *** 119,124
  1144.   #undef  PAUSE_SIG
  1145.   #define PAUSE_SIG     /* */
  1146.   #else
  1147.   #define UNCOMPRESS "/usr/ucb/uncompress"   /* for uncompressing .Z files */
  1148.   #endif
  1149.   
  1150. --- 139,148 -----
  1151.   #undef  PAUSE_SIG
  1152.   #define PAUSE_SIG     /* */
  1153.   #else
  1154. + #ifdef VMS
  1155. + #define MAXPATHLEN    500
  1156. + #define UNCOMPRESS "decompress"   /* for uncompressing .Z files */
  1157. + #endif  /* VMS */
  1158.   #define UNCOMPRESS "/usr/ucb/uncompress"   /* for uncompressing .Z files */
  1159.   #endif  /* i386 */
  1160.   
  1161. **************
  1162. *** 120,126
  1163.   #define PAUSE_SIG     /* */
  1164.   #else
  1165.   #define UNCOMPRESS "/usr/ucb/uncompress"   /* for uncompressing .Z files */
  1166. ! #endif
  1167.   
  1168.   #define PROGNAME  "xv"             /* used in resource database */
  1169.   
  1170. --- 144,150 -----
  1171.   #define UNCOMPRESS "decompress"   /* for uncompressing .Z files */
  1172.   #endif  /* VMS */
  1173.   #define UNCOMPRESS "/usr/ucb/uncompress"   /* for uncompressing .Z files */
  1174. ! #endif  /* i386 */
  1175.   
  1176.   #define PROGNAME  "xv"             /* used in resource database */
  1177.   
  1178. **************
  1179. *** 298,305
  1180.   #define RANGE(a,b,c) { if (a<b) a=b;  if (a>c) a=c; }
  1181.   
  1182.   /* PTINRECT returns '1' if x,y is in rect (inclusive) */
  1183. ! #define PTINRECT(x,y,rx,ry,rw,rh) \
  1184. !            ((x)>=(rx) && (y)>=(ry) && (x)<=(rx)+(rw) && (y)<=(ry)+(rh))
  1185.   
  1186.   /* MONO returns total intensity of r,g,b components */
  1187.   #define MONO(rd,gn,bl) (((rd)*11 + (gn)*16 + (bl)*5) >> 5)  /*.33R+ .5G+ .17B*/
  1188. --- 322,328 -----
  1189.   #define RANGE(a,b,c) { if (a<b) a=b;  if (a>c) a=c; }
  1190.   
  1191.   /* PTINRECT returns '1' if x,y is in rect (inclusive) */
  1192. ! #define PTINRECT(x,y,rx,ry,rw,rh) ((x)>=(rx) && (y)>=(ry) && (x)<=(rx)+(rw) && (y)<=(ry)+(rh))
  1193.   
  1194.   /* MONO returns total intensity of r,g,b components */
  1195.   #define MONO(rd,gn,bl) (((rd)*11 + (gn)*16 + (bl)*5) >> 5)  /*.33R+ .5G+ .17B*/
  1196. **************
  1197. *** 350,355
  1198.   
  1199.   WHERE unsigned long freecols[256]; /* list of pixel values to free */
  1200.   WHERE int           nfcols;        /* number of colors to free */
  1201.   WHERE unsigned long cols[256];     /* maps pic pixel values to X pixel vals */
  1202.   WHERE int           fc2pcol[256];  /* maps freecols into pic pixel values */
  1203.   WHERE int           numcols;       /* # of desired colors in picture */
  1204. --- 373,381 -----
  1205.   
  1206.   WHERE unsigned long freecols[256]; /* list of pixel values to free */
  1207.   WHERE int           nfcols;        /* number of colors to free */
  1208. + #ifdef VMS
  1209. + WHERE unsigned long colors[256];   /* maps pic pixel values to X pixel vals */
  1210. + #else
  1211.   WHERE unsigned long cols[256];     /* maps pic pixel values to X pixel vals */
  1212.   #endif
  1213.   WHERE int           fc2pcol[256];  /* maps freecols into pic pixel values */
  1214. **************
  1215. *** 351,356
  1216.   WHERE unsigned long freecols[256]; /* list of pixel values to free */
  1217.   WHERE int           nfcols;        /* number of colors to free */
  1218.   WHERE unsigned long cols[256];     /* maps pic pixel values to X pixel vals */
  1219.   WHERE int           fc2pcol[256];  /* maps freecols into pic pixel values */
  1220.   WHERE int           numcols;       /* # of desired colors in picture */
  1221.   WHERE int           ncols;         /* max # of (different) colors to alloc */
  1222. --- 377,383 -----
  1223.   WHERE unsigned long colors[256];   /* maps pic pixel values to X pixel vals */
  1224.   #else
  1225.   WHERE unsigned long cols[256];     /* maps pic pixel values to X pixel vals */
  1226. + #endif
  1227.   WHERE int           fc2pcol[256];  /* maps freecols into pic pixel values */
  1228.   WHERE int           numcols;       /* # of desired colors in picture */
  1229.   WHERE int           ncols;         /* max # of (different) colors to alloc */
  1230. **************
  1231. *** 370,376
  1232.                       noqcheck,      /* true if we should NOT do QuickCheck */
  1233.                       rwcolor,       /* true if we should use R/W color cells */
  1234.                       rwthistime,    /* true if we DID use R/W color cells */
  1235. -                     brokeFreeCols, /* true if server has broken XFreeColors */
  1236.                       fish,          /* turn on annoying fish */
  1237.                       fishrunning;   /* true if fish are in operation */
  1238.   
  1239. --- 397,402 -----
  1240.                       noqcheck,      /* true if we should NOT do QuickCheck */
  1241.                       rwcolor,       /* true if we should use R/W color cells */
  1242.                       rwthistime,    /* true if we DID use R/W color cells */
  1243.                       fish,          /* turn on annoying fish */
  1244.                       fishrunning;   /* true if fish are in operation */
  1245.   
  1246. **************
  1247. *** 428,433
  1248.   void WRotate(void);
  1249.   void InvCropRect(void);
  1250.   void MakeRootPic(void);
  1251.   
  1252.   /*************************** XVMISC.C ***************************/
  1253.   Window CreateWindow(char *, char *, unsigned int, unsigned int, 
  1254. --- 454,460 -----
  1255.   void WRotate(void);
  1256.   void InvCropRect(void);
  1257.   void MakeRootPic(void);
  1258. + void XvFreeColors(Display*, Colormap, unsigned long*, int, unsigned long, int);
  1259.   
  1260.   /*************************** XVMISC.C ***************************/
  1261.   Window CreateWindow(char *, char *, unsigned int, unsigned int, 
  1262. **************
  1263. *** 558,563
  1264.   int LoadXBM(char *, int);
  1265.   int WriteXBM(FILE *, byte *, int, int, char *);
  1266.   
  1267.   
  1268.   
  1269.   
  1270. --- 585,592 -----
  1271.   int LoadXBM(char *, int);
  1272.   int WriteXBM(FILE *, byte *, int, int, char *);
  1273.   
  1274. + /**************************** XVJPEG.C ***************************/
  1275. + int LoadJFIF(char *, int);
  1276.   
  1277.   
  1278.   
  1279. **************
  1280. *** 570,575
  1281.   /****************************** XV.C ****************************/
  1282.   void DrawWindow(), WCrop(), WUnCrop(), WResize(), WRotate(), InvCropRect();
  1283.   void MakeRootPic();
  1284.   
  1285.   /*************************** XVMISC.C ***************************/
  1286.   Window CreateWindow();
  1287. --- 599,605 -----
  1288.   /****************************** XV.C ****************************/
  1289.   void DrawWindow(), WCrop(), WUnCrop(), WResize(), WRotate(), InvCropRect();
  1290.   void MakeRootPic();
  1291. + void XvFreeColors();
  1292.   
  1293.   /*************************** XVMISC.C ***************************/
  1294.   Window CreateWindow();
  1295. **************
  1296. *** 632,636
  1297.   /**************************** XVXBM.C ***************************/
  1298.   int LoadXBM(), WriteXBM();
  1299.   
  1300.   
  1301.   #endif
  1302. --- 662,668 -----
  1303.   /**************************** XVXBM.C ***************************/
  1304.   int LoadXBM(), WriteXBM();
  1305.   
  1306. + /**************************** XVJPEG.C ***************************/
  1307. + int LoadJFIF();
  1308.   
  1309.   #endif
  1310. *** disk$vis:[xv.orig]xv24to8.c
  1311. --- xv24to8.c
  1312. **************
  1313. *** 73,79
  1314.   static int    Quick24to8();
  1315.   static int    QuickCheck();
  1316.   
  1317. ! static byte   tbl1[256],     /* tables used in F-S Dithering */
  1318.                 tbl3[256],     /* contain i/16, 3i/16, 5i/16, 7i/16, */
  1319.                 tbl5[256],     /* (i=0-255) respectively */
  1320.                 tbl7[256];
  1321. --- 73,79 -----
  1322.   static int    Quick24to8();
  1323.   static int    QuickCheck();
  1324.   
  1325. ! static int    tbl1[256],     /* tables used in F-S Dithering */
  1326.                 tbl3[256],     /* contain i/16, 3i/16, 5i/16, 7i/16, */
  1327.                 tbl5[256],     /* (i=-128..127) respectively */
  1328.                 tbl7[256];
  1329. **************
  1330. *** 75,81
  1331.   
  1332.   static byte   tbl1[256],     /* tables used in F-S Dithering */
  1333.                 tbl3[256],     /* contain i/16, 3i/16, 5i/16, 7i/16, */
  1334. !               tbl5[256],     /* (i=0-255) respectively */
  1335.                 tbl7[256];
  1336.   
  1337.   
  1338. --- 75,81 -----
  1339.   
  1340.   static int    tbl1[256],     /* tables used in F-S Dithering */
  1341.                 tbl3[256],     /* contain i/16, 3i/16, 5i/16, 7i/16, */
  1342. !               tbl5[256],     /* (i=-128..127) respectively */
  1343.                 tbl7[256];
  1344.   
  1345.   
  1346. **************
  1347. *** 508,516
  1348.        byte *rp,*gp,*bp;
  1349.   /*******************************/
  1350.   {
  1351. !   *rp = ((ptr->rmin + ptr->rmax) << (COLOR_DEPTH - B_DEPTH)) / 2;
  1352. !   *gp = ((ptr->gmin + ptr->gmax) << (COLOR_DEPTH - B_DEPTH)) / 2;
  1353. !   *bp = ((ptr->bmin + ptr->bmax) << (COLOR_DEPTH - B_DEPTH)) / 2;
  1354.   }
  1355.   
  1356.   
  1357. --- 508,517 -----
  1358.        byte *rp,*gp,*bp;
  1359.   /*******************************/
  1360.   {
  1361. !   /* +1 ensures that color represents the middle of the box */
  1362. !   *rp = ((ptr->rmin + ptr->rmax + 1) << (COLOR_DEPTH - B_DEPTH)) / 2;
  1363. !   *gp = ((ptr->gmin + ptr->gmax + 1) << (COLOR_DEPTH - B_DEPTH)) / 2;
  1364. !   *bp = ((ptr->bmin + ptr->bmax + 1) << (COLOR_DEPTH - B_DEPTH)) / 2;
  1365.   }
  1366.   
  1367.   
  1368. **************
  1369. *** 674,680
  1370.     int           *thisline, *nextline, *tmpptr;
  1371.     int            r1, g1, b1, r2, g2, b2;
  1372.     int            i, j, imax, jmax, oval;
  1373. !   byte          *inptr, *outptr, *tmpbptr;
  1374.     int            lastline, lastpixel;
  1375.   
  1376.     imax = HIGH - 1;
  1377. --- 675,681 -----
  1378.     int           *thisline, *nextline, *tmpptr;
  1379.     int            r1, g1, b1, r2, g2, b2;
  1380.     int            i, j, imax, jmax, oval;
  1381. !   byte          *inptr, *outptr;
  1382.     int            lastline, lastpixel;
  1383.   
  1384.     imax = HIGH - 1;
  1385. **************
  1386. *** 694,701
  1387.     outptr = (byte *) pic;
  1388.   
  1389.     /* get first line of picture */
  1390. !   for (j=WIDE * 3, tmpptr=nextline, tmpbptr=inptr; j; j--) 
  1391. !     *tmpptr++ = (int) *tmpbptr++;
  1392.   
  1393.     for (i=0; i<HIGH; i++) {
  1394.       /* swap thisline and nextline */
  1395. --- 695,702 -----
  1396.     outptr = (byte *) pic;
  1397.   
  1398.     /* get first line of picture */
  1399. !   for (j=WIDE * 3, tmpptr=nextline; j; j--) 
  1400. !     *tmpptr++ = (int) *inptr++;
  1401.   
  1402.     for (i=0; i<HIGH; i++) {
  1403.       /* swap thisline and nextline */
  1404. **************
  1405. *** 703,710
  1406.       lastline = (i==imax);
  1407.   
  1408.       /* read in next line */
  1409. !     for (j=WIDE * 3, tmpptr=nextline; j; j--) 
  1410. !       *tmpptr++ = (int) *inptr++;
  1411.   
  1412.       /* dither this line and put it into the output picture */
  1413.       thisptr = thisline;  nextptr = nextline;
  1414. --- 704,712 -----
  1415.       lastline = (i==imax);
  1416.   
  1417.       /* read in next line */
  1418. !     if (!lastline)
  1419. !       for (j=WIDE * 3, tmpptr=nextline; j; j--) 
  1420. !     *tmpptr++ = (int) *inptr++;
  1421.   
  1422.       /* dither this line and put it into the output picture */
  1423.       thisptr = thisline;  nextptr = nextline;
  1424. **************
  1425. *** 752,758
  1426.         *outptr++ = oval;
  1427.   
  1428.         r1 -= r[oval];  g1 -= g[oval];  b1 -= b[oval];
  1429. -       /* can't use tables because r1,g1,b1 go negative */
  1430.   
  1431.         if (!lastpixel) {
  1432.       thisptr[0] += (r1*7)/16;
  1433. --- 754,759 -----
  1434.         *outptr++ = oval;
  1435.   
  1436.         r1 -= r[oval];  g1 -= g[oval];  b1 -= b[oval];
  1437.   
  1438.         r1 += 128;        /* make positive for table indexing */
  1439.         g1 += 128;
  1440. **************
  1441. *** 754,759
  1442.         r1 -= r[oval];  g1 -= g[oval];  b1 -= b[oval];
  1443.         /* can't use tables because r1,g1,b1 go negative */
  1444.   
  1445.         if (!lastpixel) {
  1446.       thisptr[0] += (r1*7)/16;
  1447.       thisptr[1] += (g1*7)/16;
  1448. --- 755,764 -----
  1449.   
  1450.         r1 -= r[oval];  g1 -= g[oval];  b1 -= b[oval];
  1451.   
  1452. +       r1 += 128;        /* make positive for table indexing */
  1453. +       g1 += 128;
  1454. +       b1 += 128;
  1455.         if (!lastpixel) {
  1456.       thisptr[0] += tbl7[r1];
  1457.       thisptr[1] += tbl7[g1];
  1458. **************
  1459. *** 755,763
  1460.         /* can't use tables because r1,g1,b1 go negative */
  1461.   
  1462.         if (!lastpixel) {
  1463. !     thisptr[0] += (r1*7)/16;
  1464. !     thisptr[1] += (g1*7)/16;
  1465. !     thisptr[2] += (b1*7)/16;
  1466.         }
  1467.   
  1468.         if (!lastline) {
  1469. --- 760,768 -----
  1470.         b1 += 128;
  1471.   
  1472.         if (!lastpixel) {
  1473. !     thisptr[0] += tbl7[r1];
  1474. !     thisptr[1] += tbl7[g1];
  1475. !     thisptr[2] += tbl7[b1];
  1476.         }
  1477.   
  1478.         if (!lastline) {
  1479. **************
  1480. *** 762,770
  1481.   
  1482.         if (!lastline) {
  1483.       if (j) {
  1484. !       nextptr[-3] += (r1*3)/16;
  1485. !       nextptr[-2] += (g1*3)/16;
  1486. !       nextptr[-1] += (b1*3)/16;
  1487.       }
  1488.   
  1489.       nextptr[0] += (r1*5)/16;
  1490. --- 767,775 -----
  1491.   
  1492.         if (!lastline) {
  1493.       if (j) {
  1494. !       nextptr[-3] += tbl3[r1];
  1495. !       nextptr[-2] += tbl3[g1];
  1496. !       nextptr[-1] += tbl3[b1];
  1497.       }
  1498.   
  1499.       nextptr[0] += tbl5[r1];
  1500. **************
  1501. *** 767,775
  1502.         nextptr[-1] += (b1*3)/16;
  1503.       }
  1504.   
  1505. !     nextptr[0] += (r1*5)/16;
  1506. !     nextptr[1] += (g1*5)/16;
  1507. !     nextptr[2] += (b1*5)/16;
  1508.   
  1509.       if (!lastpixel) {
  1510.         nextptr[3] += r1/16;
  1511. --- 772,780 -----
  1512.         nextptr[-1] += tbl3[b1];
  1513.       }
  1514.   
  1515. !     nextptr[0] += tbl5[r1];
  1516. !     nextptr[1] += tbl5[g1];
  1517. !     nextptr[2] += tbl5[b1];
  1518.   
  1519.       if (!lastpixel) {
  1520.         nextptr[3] += tbl1[r1];
  1521. **************
  1522. *** 772,780
  1523.       nextptr[2] += (b1*5)/16;
  1524.   
  1525.       if (!lastpixel) {
  1526. !       nextptr[3] += r1/16;
  1527. !       nextptr[4] += g1/16;
  1528. !       nextptr[5] += b1/16;
  1529.       }
  1530.       nextptr += 3;
  1531.         }
  1532. --- 777,785 -----
  1533.       nextptr[2] += tbl5[b1];
  1534.   
  1535.       if (!lastpixel) {
  1536. !       nextptr[3] += tbl1[r1];
  1537. !       nextptr[4] += tbl1[g1];
  1538. !       nextptr[5] += tbl1[b1];
  1539.       }
  1540.       nextptr += 3;
  1541.         }
  1542. **************
  1543. *** 807,813
  1544.     byte *pp;
  1545.     int  r1, g1, b1;
  1546.     int  *thisline, *nextline, *thisptr, *nextptr, *tmpptr;
  1547. !   int  i, j, rerr, gerr, berr, pwide3;
  1548.     int  imax, jmax;
  1549.   
  1550.     pp = pic;  pwide3 = w * 3;  imax = h-1;  jmax = w-1;
  1551. --- 812,818 -----
  1552.     byte *pp;
  1553.     int  r1, g1, b1;
  1554.     int  *thisline, *nextline, *thisptr, *nextptr, *tmpptr;
  1555. !   int  i, j, val, pwide3;
  1556.     int  imax, jmax;
  1557.   
  1558.     pp = pic;  pwide3 = w * 3;  imax = h-1;  jmax = w-1;
  1559. **************
  1560. *** 812,818
  1561.   
  1562.     pp = pic;  pwide3 = w * 3;  imax = h-1;  jmax = w-1;
  1563.   
  1564. !   /* load up colormap, 3 bits R, 3 bits G, 2 bits B  (RRRGGGBB) */
  1565.     for (i=0; i<256; i++) {
  1566.       r[i] =  ((i&0xe0) * 255) / 0xe0;  
  1567.       g[i] =  ((i&0x1c) * 255) / 0x1c;
  1568. --- 817,833 -----
  1569.   
  1570.     pp = pic;  pwide3 = w * 3;  imax = h-1;  jmax = w-1;
  1571.   
  1572. !   /* up to 256 colors:     3 bits R, 3 bits G, 2 bits B  (RRRGGGBB) */
  1573. ! #define RMASK    0xe0
  1574. ! #define RSHIFT    0
  1575. ! #define GMASK    0xe0
  1576. ! #define GSHIFT    3
  1577. ! #define BMASK    0xc0
  1578. ! #define BSHIFT    6
  1579. !   /* load up colormap */
  1580. !   /* note that 0 and 255 of each color are always in the map; */
  1581. !   /* intermediate values are evenly spaced. */
  1582.     for (i=0; i<256; i++) {
  1583.       r[i] = (((i<<RSHIFT) & RMASK) * 255 + RMASK/2) / RMASK;
  1584.       g[i] = (((i<<GSHIFT) & GMASK) * 255 + GMASK/2) / GMASK;
  1585. **************
  1586. *** 814,822
  1587.   
  1588.     /* load up colormap, 3 bits R, 3 bits G, 2 bits B  (RRRGGGBB) */
  1589.     for (i=0; i<256; i++) {
  1590. !     r[i] =  ((i&0xe0) * 255) / 0xe0;  
  1591. !     g[i] =  ((i&0x1c) * 255) / 0x1c;
  1592. !     b[i] =  ((i&0x03) * 255) / 0x03;
  1593.     }
  1594.   
  1595.     thisline = (int *) malloc(pwide3 * sizeof(int));
  1596. --- 829,837 -----
  1597.     /* note that 0 and 255 of each color are always in the map; */
  1598.     /* intermediate values are evenly spaced. */
  1599.     for (i=0; i<256; i++) {
  1600. !     r[i] = (((i<<RSHIFT) & RMASK) * 255 + RMASK/2) / RMASK;
  1601. !     g[i] = (((i<<GSHIFT) & GMASK) * 255 + GMASK/2) / GMASK;
  1602. !     b[i] = (((i<<BSHIFT) & BMASK) * 255 + BMASK/2) / BMASK;
  1603.     }
  1604.   
  1605.     thisline = (int *) malloc(pwide3 * sizeof(int));
  1606. **************
  1607. *** 840,847
  1608.         r1 = *thisptr++;  g1 = *thisptr++;  b1 = *thisptr++;
  1609.         RANGE(r1,0,255);  RANGE(g1,0,255);  RANGE(b1,0,255);  
  1610.   
  1611. !       rerr = r1 & 0x1f;  gerr = g1 & 0x1f;  berr = b1 & 0x3f;
  1612. !       *pp = (r1&0xe0) | ((g1>>3)&0x1c) | (b1>>6); 
  1613.   
  1614.         if (j!=jmax) {  /* adjust RIGHT pixel */
  1615.       thisptr[0] += tbl7[rerr];
  1616. --- 855,863 -----
  1617.         r1 = *thisptr++;  g1 = *thisptr++;  b1 = *thisptr++;
  1618.         RANGE(r1,0,255);  RANGE(g1,0,255);  RANGE(b1,0,255);  
  1619.   
  1620. !       /* choose actual pixel value */
  1621. !       val = ((r1&RMASK)>>RSHIFT) | ((g1&GMASK)>>GSHIFT) | ((b1&BMASK)>>BSHIFT);
  1622. !       *pp = val;
  1623.   
  1624.         /* compute color errors */
  1625.         r1 -= r[val];
  1626. **************
  1627. *** 843,848
  1628.         rerr = r1 & 0x1f;  gerr = g1 & 0x1f;  berr = b1 & 0x3f;
  1629.         *pp = (r1&0xe0) | ((g1>>3)&0x1c) | (b1>>6); 
  1630.   
  1631.         if (j!=jmax) {  /* adjust RIGHT pixel */
  1632.       thisptr[0] += tbl7[rerr];
  1633.       thisptr[1] += tbl7[gerr];
  1634. --- 859,874 -----
  1635.         val = ((r1&RMASK)>>RSHIFT) | ((g1&GMASK)>>GSHIFT) | ((b1&BMASK)>>BSHIFT);
  1636.         *pp = val;
  1637.   
  1638. +       /* compute color errors */
  1639. +       r1 -= r[val];
  1640. +       g1 -= g[val];
  1641. +       b1 -= b[val];
  1642. +       /* Add fractions of errors to adjacent pixels */
  1643. +       r1 += 128;        /* make positive for table indexing */
  1644. +       g1 += 128;
  1645. +       b1 += 128;
  1646.         if (j!=jmax) {  /* adjust RIGHT pixel */
  1647.       thisptr[0] += tbl7[r1];
  1648.       thisptr[1] += tbl7[g1];
  1649. **************
  1650. *** 844,852
  1651.         *pp = (r1&0xe0) | ((g1>>3)&0x1c) | (b1>>6); 
  1652.   
  1653.         if (j!=jmax) {  /* adjust RIGHT pixel */
  1654. !     thisptr[0] += tbl7[rerr];
  1655. !     thisptr[1] += tbl7[gerr];
  1656. !     thisptr[2] += tbl7[berr];
  1657.         }
  1658.         
  1659.         if (i!=imax) {    /* do BOTTOM pixel */
  1660. --- 870,878 -----
  1661.         b1 += 128;
  1662.   
  1663.         if (j!=jmax) {  /* adjust RIGHT pixel */
  1664. !     thisptr[0] += tbl7[r1];
  1665. !     thisptr[1] += tbl7[g1];
  1666. !     thisptr[2] += tbl7[b1];
  1667.         }
  1668.         
  1669.         if (i!=imax) {    /* do BOTTOM pixel */
  1670. **************
  1671. *** 850,858
  1672.         }
  1673.         
  1674.         if (i!=imax) {    /* do BOTTOM pixel */
  1675. !     nextptr[0] += tbl5[rerr];
  1676. !     nextptr[1] += tbl5[gerr];
  1677. !     nextptr[2] += tbl5[berr];
  1678.   
  1679.       if (j>0) {  /* do BOTTOM LEFT pixel */
  1680.         nextptr[-3] += tbl3[rerr];
  1681. --- 876,884 -----
  1682.         }
  1683.         
  1684.         if (i!=imax) {    /* do BOTTOM pixel */
  1685. !     nextptr[0] += tbl5[r1];
  1686. !     nextptr[1] += tbl5[g1];
  1687. !     nextptr[2] += tbl5[b1];
  1688.   
  1689.       if (j>0) {  /* do BOTTOM LEFT pixel */
  1690.         nextptr[-3] += tbl3[r1];
  1691. **************
  1692. *** 855,863
  1693.       nextptr[2] += tbl5[berr];
  1694.   
  1695.       if (j>0) {  /* do BOTTOM LEFT pixel */
  1696. !       nextptr[-3] += tbl3[rerr];
  1697. !       nextptr[-2] += tbl3[gerr];
  1698. !       nextptr[-1] += tbl3[berr];
  1699.       }
  1700.   
  1701.       if (j!=jmax) {  /* do BOTTOM RIGHT pixel */
  1702. --- 881,889 -----
  1703.       nextptr[2] += tbl5[b1];
  1704.   
  1705.       if (j>0) {  /* do BOTTOM LEFT pixel */
  1706. !       nextptr[-3] += tbl3[r1];
  1707. !       nextptr[-2] += tbl3[g1];
  1708. !       nextptr[-1] += tbl3[b1];
  1709.       }
  1710.   
  1711.       if (j!=jmax) {  /* do BOTTOM RIGHT pixel */
  1712. **************
  1713. *** 861,869
  1714.       }
  1715.   
  1716.       if (j!=jmax) {  /* do BOTTOM RIGHT pixel */
  1717. !       nextptr[3] += tbl1[rerr];
  1718. !       nextptr[4] += tbl1[gerr];
  1719. !       nextptr[5] += tbl1[berr];
  1720.       }
  1721.       nextptr += 3;
  1722.         }
  1723. --- 887,895 -----
  1724.       }
  1725.   
  1726.       if (j!=jmax) {  /* do BOTTOM RIGHT pixel */
  1727. !       nextptr[3] += tbl1[r1];
  1728. !       nextptr[4] += tbl1[g1];
  1729. !       nextptr[5] += tbl1[b1];
  1730.       }
  1731.       nextptr += 3;
  1732.         }
  1733. **************
  1734. *** 880,890
  1735.   /****************************/
  1736.   {
  1737.     int i;
  1738. !   for (i=0; i<256; i++) {     /* initialize Floyd-Steinberg division tables */
  1739. !     tbl1[i] = i/16;
  1740. !     tbl3[i] = (3*i)/16;
  1741. !     tbl5[i] = (5*i)/16;
  1742. !     tbl7[i] = (7*i)/16;
  1743.     }
  1744.   }
  1745.   
  1746. --- 906,926 -----
  1747.   /****************************/
  1748.   {
  1749.     int i;
  1750. !   /* initialize Floyd-Steinberg division tables */
  1751. !   /* make sure rounding is done correctly for negative values! */
  1752. !   for (i = -128; i < 0; i++) {
  1753. !     tbl1[i+128] = -((8 -i  )/16);
  1754. !     tbl3[i+128] = -((8 -3*i)/16);
  1755. !     tbl5[i+128] = -((8 -5*i)/16);
  1756. !     tbl7[i+128] = -((8 -7*i)/16);
  1757. !   }
  1758. !   for (i = 0; i < 128; i++) {
  1759. !     tbl1[i+128] = (i  +8)/16;
  1760. !     tbl3[i+128] = (3*i+8)/16;
  1761. !     tbl5[i+128] = (5*i+8)/16;
  1762. !     tbl7[i+128] = (7*i+8)/16;
  1763.     }
  1764.   }
  1765.   
  1766. *** disk$vis:[xv.orig]xvdir.c
  1767. --- xvdir.c
  1768. **************
  1769. *** 336,342
  1770.   
  1771.     numdirnames = 0;
  1772.   
  1773. ! #ifdef SYSV
  1774.     getcwd(path, sizeof(path));
  1775.   #else
  1776.     getwd(path);
  1777. --- 336,342 -----
  1778.   
  1779.     numdirnames = 0;
  1780.   
  1781. ! #if (defined(SYSV) || defined(SVR4) || defined(VMS))
  1782.     getcwd(path, sizeof(path));
  1783.   #else
  1784.     getwd(path);
  1785. **************
  1786. *** 385,391
  1787.         /* figure out what type of file the beastie is */
  1788.         dirnames[i][0] = C_REG;   /* default to normal file, if lstat fails */
  1789.   
  1790. ! #if defined(i386) || defined (SYSV)
  1791.         if (stat(dirnames[i]+1, &st)==0) {
  1792.   #else
  1793.         if (lstat(dirnames[i]+1, &st)==0) {
  1794. --- 385,391 -----
  1795.         /* figure out what type of file the beastie is */
  1796.         dirnames[i][0] = C_REG;   /* default to normal file, if lstat fails */
  1797.   
  1798. ! #if defined(i386) || defined (SYSV) || defined (VMS)
  1799.         if (stat(dirnames[i]+1, &st)==0) {
  1800.   #else
  1801.         if (lstat(dirnames[i]+1, &st)==0) {
  1802. **************
  1803. *** 425,431
  1804.     RedrawDirW(0,0,DIRWIDE,DIRHIGH);
  1805.   }
  1806.   
  1807.   /***************************************************/
  1808.   static int dnamcmp(s1,s2)
  1809.   char **s1, **s2;
  1810. --- 425,430 -----
  1811.     RedrawDirW(0,0,DIRWIDE,DIRHIGH);
  1812.   }
  1813.   
  1814.   /***************************************************/
  1815.   static int dnamcmp(s1,s2)
  1816.   char **s1, **s2;
  1817. **************
  1818. *** 539,544
  1819.     /* open file */
  1820.     fp = fopen(filename, "w");
  1821.     if (!fp) {
  1822.       SetISTR(ISTR_INFO,"Can't create '%s' -  %s",filename,sys_errlist[errno]);
  1823.       Warning();
  1824.       if (bwpic) free(bwpic);
  1825. --- 538,546 -----
  1826.     /* open file */
  1827.     fp = fopen(filename, "w");
  1828.     if (!fp) {
  1829. + #ifdef VMS
  1830. +     SetISTR(ISTR_INFO,"Can't create '%s'",filename);
  1831. + #else
  1832.       SetISTR(ISTR_INFO,"Can't create '%s' -  %s",filename,sys_errlist[errno]);
  1833.   #endif
  1834.       Warning();
  1835. **************
  1836. *** 540,545
  1837.     fp = fopen(filename, "w");
  1838.     if (!fp) {
  1839.       SetISTR(ISTR_INFO,"Can't create '%s' -  %s",filename,sys_errlist[errno]);
  1840.       Warning();
  1841.       if (bwpic) free(bwpic);
  1842.       SetCursors(-1);
  1843. --- 542,548 -----
  1844.       SetISTR(ISTR_INFO,"Can't create '%s'",filename);
  1845.   #else
  1846.       SetISTR(ISTR_INFO,"Can't create '%s' -  %s",filename,sys_errlist[errno]);
  1847. + #endif
  1848.       Warning();
  1849.       if (bwpic) free(bwpic);
  1850.       SetCursors(-1);
  1851. *** disk$vis:[xv.orig]xvfish.c
  1852. --- xvfish.c
  1853. **************
  1854. *** 103,108
  1855.   StopFish()
  1856.   /**************/
  1857.   {
  1858.     struct itimerval it;
  1859.   #ifdef POSIX
  1860.     struct sigaction act;
  1861. --- 103,109 -----
  1862.   StopFish()
  1863.   /**************/
  1864.   {
  1865. + #ifndef VMS
  1866.     struct itimerval it;
  1867.   #endif
  1868.   #ifdef POSIX
  1869. **************
  1870. *** 104,109
  1871.   /**************/
  1872.   {
  1873.     struct itimerval it;
  1874.   #ifdef POSIX
  1875.     struct sigaction act;
  1876.   #endif
  1877. --- 105,111 -----
  1878.   {
  1879.   #ifndef VMS
  1880.     struct itimerval it;
  1881. + #endif
  1882.   #ifdef POSIX
  1883.     struct sigaction act;
  1884.   #endif
  1885. **************
  1886. *** 121,126
  1887.   #endif
  1888.   
  1889.   
  1890.     bzero(&it, sizeof(it));
  1891.     it.it_interval.tv_usec = 0L;
  1892.     it.it_value.tv_usec = 0L;
  1893. --- 123,129 -----
  1894.   #endif
  1895.   
  1896.   
  1897. + #ifndef VMS
  1898.     bzero(&it, sizeof(it));
  1899.     it.it_interval.tv_usec = 0L;
  1900.     it.it_value.tv_usec = 0L;
  1901. **************
  1902. *** 135,140
  1903.     RELEASE_SIG;          /* allow ALRM signals to happen (we don't get them) */
  1904.     fishrunning = 0;
  1905.   #endif /* POSIX */  
  1906.   }
  1907.   
  1908.   
  1909. --- 138,144 -----
  1910.     RELEASE_SIG;          /* allow ALRM signals to happen (we don't get them) */
  1911.     fishrunning = 0;
  1912.   #endif /* POSIX */  
  1913. + #endif /* VMS */
  1914.   }
  1915.   
  1916.   
  1917. **************
  1918. *** 177,182
  1919.   static void setfishtimer()
  1920.   /*******/
  1921.   {
  1922.     struct itimerval it;
  1923.   #ifdef POSIX
  1924.     struct sigaction act;
  1925. --- 181,187 -----
  1926.   static void setfishtimer()
  1927.   /*******/
  1928.   {
  1929. + #ifndef VMS
  1930.     struct itimerval it;
  1931.   #endif
  1932.   #ifdef POSIX
  1933. **************
  1934. *** 178,183
  1935.   /*******/
  1936.   {
  1937.     struct itimerval it;
  1938.   #ifdef POSIX
  1939.     struct sigaction act;
  1940.   #endif
  1941. --- 183,189 -----
  1942.   {
  1943.   #ifndef VMS
  1944.     struct itimerval it;
  1945. + #endif
  1946.   #ifdef POSIX
  1947.     struct sigaction act;
  1948.   #endif
  1949. **************
  1950. *** 181,186
  1951.   #ifdef POSIX
  1952.     struct sigaction act;
  1953.   #endif
  1954.        
  1955.     bzero(&it, sizeof(it));
  1956.     it.it_value.tv_usec = DELAY;
  1957. --- 187,193 -----
  1958.   #ifdef POSIX
  1959.     struct sigaction act;
  1960.   #endif
  1961. + #ifndef VMS
  1962.        
  1963.     bzero(&it, sizeof(it));
  1964.     it.it_value.tv_usec = DELAY;
  1965. **************
  1966. *** 193,198
  1967.     RELEASE_SIG;               /* enable ALRM signals */
  1968.     setitimer(ITIMER_REAL, &it, (struct itimerval *)0);
  1969.   #endif /* POSIX */
  1970.   }
  1971.   
  1972.   
  1973. --- 200,206 -----
  1974.     RELEASE_SIG;               /* enable ALRM signals */
  1975.     setitimer(ITIMER_REAL, &it, (struct itimerval *)0);
  1976.   #endif /* POSIX */
  1977. + #endif /* VMS */
  1978.   }
  1979.   
  1980.   
  1981. *** disk$vis:[xv.orig]xvgam.c
  1982. --- xvgam.c
  1983. **************
  1984. *** 620,640
  1985.       LocalCmap = 0;
  1986.     }
  1987.     else {
  1988. !     if (!brokeFreeCols) {
  1989. !       for (i=0; i<nfcols; i++) 
  1990. !     XFreeColors(theDisp, theCmap, &freecols[i], 1, 0L);
  1991. !     }
  1992. !     else {
  1993. !       for (i=0; i<nfcols; i++) {
  1994. !     int j;
  1995. !     for (j=0; j<i; j++) {
  1996. !       if (freecols[i] == freecols[j])   /* already been freed once */
  1997. !         break;
  1998. !     }
  1999. !     if (j==i)      /* wasn't found in already-freed list */
  2000. !       XFreeColors(theDisp, theCmap, &freecols[i], 1, 0L);
  2001. !       }
  2002. !     }
  2003.   
  2004.       if (nfcols) {
  2005.         XFlush(theDisp);  /* just to make sure they're all freed right now... */
  2006. --- 620,626 -----
  2007.       LocalCmap = 0;
  2008.     }
  2009.     else {
  2010. !     XvFreeColors(theDisp, theCmap, freecols, 1, 0L, nfcols);
  2011.   
  2012.       if (nfcols) {
  2013.         XFlush(theDisp);  /* just to make sure they're all freed right now... */
  2014. *** disk$vis:[xv.orig]xvgif.c
  2015. --- xvgif.c
  2016. **************
  2017. *** 88,94
  2018.       /* An output array used by the decompressor */
  2019.   int OutCode[1025];
  2020.   
  2021. ! char *id = "GIF87a";
  2022.   
  2023.   static int EGApalette[16][3] = {
  2024.     {0,0,0},       {0,0,128},     {0,128,0},     {0,128,128}, 
  2025. --- 88,95 -----
  2026.       /* An output array used by the decompressor */
  2027.   int OutCode[1025];
  2028.   
  2029. ! char *id87 = "GIF87a";
  2030. ! char *id89 = "GIF89a";
  2031.   
  2032.   static int EGApalette[16][3] = {
  2033.     {0,0,0},       {0,0,128},     {0,128,0},     {0,128,128}, 
  2034. **************
  2035. *** 140,146
  2036.     if (fread(ptr, filesize, 1, fp) != 1) 
  2037.       return( GifError("GIF data read failed") );
  2038.     
  2039. !   if (strncmp(ptr, id, 6)) 
  2040.       return( GifError("not a GIF file"));
  2041.     
  2042.     ptr += 6;
  2043. --- 141,147 -----
  2044.     if (fread(ptr, filesize, 1, fp) != 1) 
  2045.       return( GifError("GIF data read failed") );
  2046.     
  2047. !   if (strncmp(ptr, id87, 6) && strncmp(ptr, id89, 6)) 
  2048.       return( GifError("not a GIF file"));
  2049.     
  2050.     ptr += 6;
  2051. *** disk$vis:[xv.orig]xvmisc.c
  2052. --- xvmisc.c
  2053. **************
  2054. *** 200,208
  2055.   /************************************************/
  2056.   
  2057.   typedef struct thing 
  2058. !     { byte r,g,b; 
  2059. !       int oldindex; 
  2060. !       int use; } CMAPENT;
  2061.   
  2062.   
  2063.   static int CMAPcompare(a,b)
  2064. --- 200,210 -----
  2065.   /************************************************/
  2066.   
  2067.   typedef struct thing 
  2068. !     { byte r,g,b;        /* actual value of color */
  2069. !       int oldindex;        /* its index in the old colormap */
  2070. !       int use;            /* # of pixels of this color */
  2071. !       int mindist;        /* min distance to a selected color */
  2072. !     } CMAPENT;
  2073.   
  2074.   
  2075.   /***********************************/
  2076. **************
  2077. *** 205,217
  2078.         int use; } CMAPENT;
  2079.   
  2080.   
  2081. - static int CMAPcompare(a,b)
  2082. - CMAPENT *a,*b;
  2083. - {
  2084. -   return (b->use - a->use);
  2085. - }
  2086.   /***********************************/
  2087.   void SortColormap()
  2088.   {
  2089. --- 207,212 -----
  2090.       } CMAPENT;
  2091.   
  2092.   
  2093.   /***********************************/
  2094.   void SortColormap()
  2095.   {
  2096. **************
  2097. *** 216,223
  2098.   void SortColormap()
  2099.   {
  2100.     byte *p;
  2101. !   int   i, j, k, mdist, entry, mn, d, hist[256], trans[256];
  2102. !   static CMAPENT c[256], c1[256], *cp, *cj, *ck;
  2103.   
  2104.   
  2105.     /* no point doing this if we're on a 1-bit display */
  2106. --- 211,218 -----
  2107.   void SortColormap()
  2108.   {
  2109.     byte *p;
  2110. !   int   i, j, k, mdist, entry, d, hist[256], trans[256];
  2111. !   CMAPENT c[256], c1[256], *cp, *cj, *ck;
  2112.   
  2113.   
  2114.     /* no point doing this if we're on a 1-bit display */
  2115. **************
  2116. *** 243,248
  2117.         cp = &c[numcols++];
  2118.         cp->r = r[i];  cp->g = g[i];  cp->b = b[i];
  2119.         cp->use = hist[i];  cp->oldindex = i;
  2120.       }
  2121.     }
  2122.   
  2123. --- 238,244 -----
  2124.         cp = &c[numcols++];
  2125.         cp->r = r[i];  cp->g = g[i];  cp->b = b[i];
  2126.         cp->use = hist[i];  cp->oldindex = i;
  2127. +       cp->mindist = 100000;
  2128.       }
  2129.     }
  2130.   
  2131. **************
  2132. *** 256,273
  2133.     c[entry].use = 0;   /* and mark it dealt with */
  2134.     
  2135.     
  2136. !   /* sort rest of colormap, in order of decreasing 'distance' from already
  2137. !      allocated elements.
  2138. !   
  2139. !      FURTHER MODIFICATION of algorithm.  The algorithm's performance
  2140. !      utterly goes to hell as numcols increases.  (Probably on the order
  2141. !      of O^3 performance).  Since I don't see a clever way of rewriting
  2142. !      the algorithm for O^2 performance (which'd be acceptable), I'm going
  2143. !      to make a trade-off.  I'll only run the algorithm for the first 32 colors
  2144. !      (or so).  It can do that Real Fast.  Then I'll just stick the rest of
  2145. !      the unsorted colors (if any), and tack them on the end, in order of
  2146. !      amount of use.  This should give similar picture quality, with 
  2147. !      much higher performance. */
  2148.   
  2149.     for (i=1; i<numcols && i<32; i++) {
  2150.       /* find the i'th most different color */
  2151. --- 252,260 -----
  2152.     c[entry].use = 0;   /* and mark it dealt with */
  2153.     
  2154.     
  2155. !   /* sort rest of colormap.  Half of the entries are allocated on the
  2156. !      basis of distance from already allocated colors, and half on the
  2157. !      basis of usage.  (NB: 'taxicab' distance is used throughout this file.)
  2158.   
  2159.        To obtain O(n^2) performance, we keep each unselected color
  2160.        (in c[], with use>0) marked with the minimum distance to any of
  2161. **************
  2162. *** 269,277
  2163.        amount of use.  This should give similar picture quality, with 
  2164.        much higher performance. */
  2165.   
  2166. !   for (i=1; i<numcols && i<32; i++) {
  2167. !     /* find the i'th most different color */
  2168. !     entry = -1;  mdist = -1;
  2169.       for (j=0, cj=c; j<numcols; j++,cj++) {
  2170.         if (cj->use) {  /* this color has not been marked already */
  2171.       mn = 10000;
  2172. --- 256,269 -----
  2173.        basis of distance from already allocated colors, and half on the
  2174.        basis of usage.  (NB: 'taxicab' distance is used throughout this file.)
  2175.   
  2176. !      To obtain O(n^2) performance, we keep each unselected color
  2177. !      (in c[], with use>0) marked with the minimum distance to any of
  2178. !      the selected colors (in c1[]).  Each time we select a color, we
  2179. !      can update the minimum distances in O(n) time. */
  2180. !   for (i=1; i<numcols; i++) {
  2181. !     /* First, update distances to the just-selected color */
  2182. !     ck = &c1[i-1];        /* point to just-selected color */
  2183.       for (j=0, cj=c; j<numcols; j++,cj++) {
  2184.         if (cj->use) {  /* can ignore already-selected colors */
  2185.         d = abs(cj->r - ck->r) + abs(cj->g - ck->g) + abs(cj->b - ck->b);
  2186. **************
  2187. *** 273,281
  2188.       /* find the i'th most different color */
  2189.       entry = -1;  mdist = -1;
  2190.       for (j=0, cj=c; j<numcols; j++,cj++) {
  2191. !       if (cj->use) {  /* this color has not been marked already */
  2192. !     mn = 10000;
  2193. !     for (k=0, ck=c1; k<i; k++,ck++) {
  2194.         d = abs(cj->r - ck->r) + abs(cj->g - ck->g) + abs(cj->b - ck->b);
  2195.         if (mn>d) mn=d;
  2196.       }
  2197. --- 265,271 -----
  2198.       /* First, update distances to the just-selected color */
  2199.       ck = &c1[i-1];        /* point to just-selected color */
  2200.       for (j=0, cj=c; j<numcols; j++,cj++) {
  2201. !       if (cj->use) {  /* can ignore already-selected colors */
  2202.         d = abs(cj->r - ck->r) + abs(cj->g - ck->g) + abs(cj->b - ck->b);
  2203.         if (cj->mindist > d) cj->mindist = d;
  2204.       }
  2205. **************
  2206. *** 277,283
  2207.       mn = 10000;
  2208.       for (k=0, ck=c1; k<i; k++,ck++) {
  2209.         d = abs(cj->r - ck->r) + abs(cj->g - ck->g) + abs(cj->b - ck->b);
  2210. !       if (mn>d) mn=d;
  2211.       }
  2212.       /* mn = minimum distance from c[j] to already used colors */
  2213.       /* we want to select the unused color that has the greatest mn */
  2214. --- 267,273 -----
  2215.       for (j=0, cj=c; j<numcols; j++,cj++) {
  2216.         if (cj->use) {  /* can ignore already-selected colors */
  2217.         d = abs(cj->r - ck->r) + abs(cj->g - ck->g) + abs(cj->b - ck->b);
  2218. !       if (cj->mindist > d) cj->mindist = d;
  2219.       }
  2220.       }
  2221.   
  2222. **************
  2223. *** 279,288
  2224.         d = abs(cj->r - ck->r) + abs(cj->g - ck->g) + abs(cj->b - ck->b);
  2225.         if (mn>d) mn=d;
  2226.       }
  2227. -     /* mn = minimum distance from c[j] to already used colors */
  2228. -     /* we want to select the unused color that has the greatest mn */
  2229. -     if (mn > mdist) { mdist = mn;  entry = j; }
  2230. -       }
  2231.       }
  2232.       
  2233.       /* c[entry] is the next color to put in the map.  do so */
  2234. --- 269,274 -----
  2235.         d = abs(cj->r - ck->r) + abs(cj->g - ck->g) + abs(cj->b - ck->b);
  2236.         if (cj->mindist > d) cj->mindist = d;
  2237.       }
  2238.       }
  2239.   
  2240.       if (i&1) {
  2241. **************
  2242. *** 284,289
  2243.       if (mn > mdist) { mdist = mn;  entry = j; }
  2244.         }
  2245.       }
  2246.       
  2247.       /* c[entry] is the next color to put in the map.  do so */
  2248.       memcpy(&c1[i], &c[entry], sizeof(CMAPENT));
  2249. --- 270,295 -----
  2250.         if (cj->mindist > d) cj->mindist = d;
  2251.       }
  2252.       }
  2253. +     if (i&1) {
  2254. +       /* Now find the i'th most different color */
  2255. +       /* we want to select the unused color that has the greatest mindist */
  2256. +       entry = -1;  mdist = -1;
  2257. +       for (j=0, cj=c; j<numcols; j++,cj++) {
  2258. +     if (cj->use) {  /* this color has not been marked already */
  2259. +       if (cj->mindist > mdist) { mdist = cj->mindist;  entry = j; }
  2260. +     }
  2261. +       }
  2262. +     } else {
  2263. +       /* Now find the i'th most different color */
  2264. +       /* we want to select the unused color that has the greatest usage */
  2265. +       entry = -1;  mdist = -1;
  2266. +       for (j=0, cj=c; j<numcols; j++,cj++) {
  2267. +     if (cj->use) {  /* this color has not been marked already */
  2268. +       if (cj->use > mdist) { mdist = cj->use;  entry = j; }
  2269. +     }
  2270. +       }
  2271. +     }
  2272.       
  2273.       /* c[entry] is the next color to put in the map.  do so */
  2274.       memcpy(&c1[i], &c[entry], sizeof(CMAPENT));
  2275. **************
  2276. *** 290,300
  2277.       c[entry].use = 0;
  2278.     }
  2279.     
  2280. -   /* tack rest of colors onto colormap in decreasing order of use */
  2281. -   qsort((char *) c,numcols,sizeof(CMAPENT),CMAPcompare);
  2282. -   memcpy(&c1[i], c, (numcols - i) * sizeof(CMAPENT));
  2283.     /* build translation table */
  2284.     for (i=0; i<numcols; i++) trans[ c1[i].oldindex ] = i;
  2285.     
  2286. --- 296,301 -----
  2287.       c[entry].use = 0;
  2288.     }
  2289.     
  2290.     /* build translation table */
  2291.     for (i=0; i<numcols; i++) trans[ c1[i].oldindex ] = i;
  2292.     
  2293. **************
  2294. *** 358,363
  2295.        because when I say 'allocate me 32 colors' I want it to allocate
  2296.        32 different colors, not 32 instances of the same 4 shades... */
  2297.     
  2298.     for (i=0; i<numcols; i++) cols[i] = NOPIX;
  2299.     
  2300.     cmap = theCmap;
  2301. --- 359,367 -----
  2302.        because when I say 'allocate me 32 colors' I want it to allocate
  2303.        32 different colors, not 32 instances of the same 4 shades... */
  2304.     
  2305. + #ifdef VMS
  2306. +   for (i=0; i<numcols; i++) colors[i] = NOPIX;
  2307. + #else
  2308.     for (i=0; i<numcols; i++) cols[i] = NOPIX;
  2309.   #endif
  2310.     
  2311. **************
  2312. *** 359,364
  2313.        32 different colors, not 32 instances of the same 4 shades... */
  2314.     
  2315.     for (i=0; i<numcols; i++) cols[i] = NOPIX;
  2316.     
  2317.     cmap = theCmap;
  2318.     for (i=0; i<numcols && unique<ncols; i++) {
  2319. --- 363,369 -----
  2320.     for (i=0; i<numcols; i++) colors[i] = NOPIX;
  2321.   #else
  2322.     for (i=0; i<numcols; i++) cols[i] = NOPIX;
  2323. + #endif
  2324.     
  2325.     cmap = theCmap;
  2326.     for (i=0; i<numcols && unique<ncols; i++) {
  2327. **************
  2328. *** 370,375
  2329.       if (XAllocColor(theDisp, cmap, &defs[i])) { 
  2330.         unsigned long pixel, *fcptr;
  2331.         
  2332.         pixel = cols[i] = defs[i].pixel;
  2333.         
  2334.         /* see if the newly allocated color is new and different */
  2335. --- 375,383 -----
  2336.       if (XAllocColor(theDisp, cmap, &defs[i])) { 
  2337.         unsigned long pixel, *fcptr;
  2338.         
  2339. + #ifdef VMS
  2340. +       pixel = colors[i] = defs[i].pixel;
  2341. + #else
  2342.         pixel = cols[i] = defs[i].pixel;
  2343.   #endif
  2344.         
  2345. **************
  2346. *** 371,376
  2347.         unsigned long pixel, *fcptr;
  2348.         
  2349.         pixel = cols[i] = defs[i].pixel;
  2350.         
  2351.         /* see if the newly allocated color is new and different */
  2352.         for (j=0, fcptr=freecols; j<nfcols && *fcptr!=pixel; j++,fcptr++);
  2353. --- 379,385 -----
  2354.         pixel = colors[i] = defs[i].pixel;
  2355.   #else
  2356.         pixel = cols[i] = defs[i].pixel;
  2357. + #endif
  2358.         
  2359.         /* see if the newly allocated color is new and different */
  2360.         for (j=0, fcptr=freecols; j<nfcols && *fcptr!=pixel; j++,fcptr++);
  2361. **************
  2362. *** 395,400
  2363.          allocated our own colormap, and have STILL run out of colors
  2364.          (possible, even on an 8 bit display), just mark pixel as
  2365.          unallocated.  We'll deal with it later */
  2366.       cols[i] = NOPIX;
  2367.       }
  2368.     }  /* FIRST PASS */
  2369. --- 404,412 -----
  2370.          allocated our own colormap, and have STILL run out of colors
  2371.          (possible, even on an 8 bit display), just mark pixel as
  2372.          unallocated.  We'll deal with it later */
  2373. + #ifdef VMS
  2374. +     colors[i] = NOPIX;
  2375. + #else
  2376.       cols[i] = NOPIX;
  2377.   #endif
  2378.       }
  2379. **************
  2380. *** 396,401
  2381.          (possible, even on an 8 bit display), just mark pixel as
  2382.          unallocated.  We'll deal with it later */
  2383.       cols[i] = NOPIX;
  2384.       }
  2385.     }  /* FIRST PASS */
  2386.     
  2387. --- 408,414 -----
  2388.       colors[i] = NOPIX;
  2389.   #else
  2390.       cols[i] = NOPIX;
  2391. + #endif
  2392.       }
  2393.     }  /* FIRST PASS */
  2394.     
  2395. **************
  2396. *** 434,439
  2397.     XQueryColors(theDisp, cmap, ctab, dc);
  2398.   
  2399.     for (i=0; i<numcols && unique<ncols; i++)
  2400.       if (cols[i]==NOPIX) {  /* an unallocated pixel */
  2401.         int           d, mdist, close;
  2402.         unsigned long ri,gi,bi;
  2403. --- 447,455 -----
  2404.     XQueryColors(theDisp, cmap, ctab, dc);
  2405.   
  2406.     for (i=0; i<numcols && unique<ncols; i++)
  2407. + #ifdef VMS
  2408. +     if (colors[i]==NOPIX) {  /* an unallocated pixel */
  2409. + #else
  2410.       if (cols[i]==NOPIX) {  /* an unallocated pixel */
  2411.   #endif
  2412.         int           d, mdist, close;
  2413. **************
  2414. *** 435,440
  2415.   
  2416.     for (i=0; i<numcols && unique<ncols; i++)
  2417.       if (cols[i]==NOPIX) {  /* an unallocated pixel */
  2418.         int           d, mdist, close;
  2419.         unsigned long ri,gi,bi;
  2420.   
  2421. --- 451,457 -----
  2422.       if (colors[i]==NOPIX) {  /* an unallocated pixel */
  2423.   #else
  2424.       if (cols[i]==NOPIX) {  /* an unallocated pixel */
  2425. + #endif
  2426.         int           d, mdist, close;
  2427.         unsigned long ri,gi,bi;
  2428.   
  2429. **************
  2430. *** 451,456
  2431.         if (close<0) FatalError("This Can't Happen! (How reassuring.)");
  2432.         if (XAllocColor(theDisp, cmap, &ctab[close])) { 
  2433.       memcpy(&defs[i], &ctab[close], sizeof(XColor));
  2434.       cols[i] = ctab[close].pixel;
  2435.       fc2pcol[nfcols] = i;
  2436.       freecols[nfcols++] = cols[i];
  2437. --- 468,476 -----
  2438.         if (close<0) FatalError("This Can't Happen! (How reassuring.)");
  2439.         if (XAllocColor(theDisp, cmap, &ctab[close])) { 
  2440.       memcpy(&defs[i], &ctab[close], sizeof(XColor));
  2441. + #ifdef VMS
  2442. +     colors[i] = ctab[close].pixel;
  2443. + #else
  2444.       cols[i] = ctab[close].pixel;
  2445.   #endif
  2446.       fc2pcol[nfcols] = i;
  2447. **************
  2448. *** 452,457
  2449.         if (XAllocColor(theDisp, cmap, &ctab[close])) { 
  2450.       memcpy(&defs[i], &ctab[close], sizeof(XColor));
  2451.       cols[i] = ctab[close].pixel;
  2452.       fc2pcol[nfcols] = i;
  2453.       freecols[nfcols++] = cols[i];
  2454.       p2alloc++;
  2455. --- 472,478 -----
  2456.       colors[i] = ctab[close].pixel;
  2457.   #else
  2458.       cols[i] = ctab[close].pixel;
  2459. + #endif
  2460.       fc2pcol[nfcols] = i;
  2461.   #ifdef VMS
  2462.       freecols[nfcols++] = colors[i];
  2463. **************
  2464. *** 453,458
  2465.       memcpy(&defs[i], &ctab[close], sizeof(XColor));
  2466.       cols[i] = ctab[close].pixel;
  2467.       fc2pcol[nfcols] = i;
  2468.       freecols[nfcols++] = cols[i];
  2469.       p2alloc++;
  2470.       unique++;
  2471. --- 474,482 -----
  2472.       cols[i] = ctab[close].pixel;
  2473.   #endif
  2474.       fc2pcol[nfcols] = i;
  2475. + #ifdef VMS
  2476. +     freecols[nfcols++] = colors[i];
  2477. + #else
  2478.       freecols[nfcols++] = cols[i];
  2479.   #endif
  2480.       p2alloc++;
  2481. **************
  2482. *** 454,459
  2483.       cols[i] = ctab[close].pixel;
  2484.       fc2pcol[nfcols] = i;
  2485.       freecols[nfcols++] = cols[i];
  2486.       p2alloc++;
  2487.       unique++;
  2488.         }
  2489. --- 478,484 -----
  2490.       freecols[nfcols++] = colors[i];
  2491.   #else
  2492.       freecols[nfcols++] = cols[i];
  2493. + #endif
  2494.       p2alloc++;
  2495.       unique++;
  2496.         }
  2497. **************
  2498. *** 467,472
  2499.        (noglob), or B) the colors found in the X colormap */
  2500.   
  2501.     for (i=0; i<numcols; i++) {
  2502.       if (cols[i] == NOPIX) {  /* an unallocated pixel */
  2503.         int           d, k, mdist, close;
  2504.         unsigned long ri,gi,bi;
  2505. --- 492,500 -----
  2506.        (noglob), or B) the colors found in the X colormap */
  2507.   
  2508.     for (i=0; i<numcols; i++) {
  2509. + #ifdef VMS
  2510. +     if (colors[i] == NOPIX) {  /* an unallocated pixel */
  2511. + #else
  2512.       if (cols[i] == NOPIX) {  /* an unallocated pixel */
  2513.   #endif
  2514.         int           d, k, mdist, close;
  2515. **************
  2516. *** 468,473
  2517.   
  2518.     for (i=0; i<numcols; i++) {
  2519.       if (cols[i] == NOPIX) {  /* an unallocated pixel */
  2520.         int           d, k, mdist, close;
  2521.         unsigned long ri,gi,bi;
  2522.   
  2523. --- 496,502 -----
  2524.       if (colors[i] == NOPIX) {  /* an unallocated pixel */
  2525.   #else
  2526.       if (cols[i] == NOPIX) {  /* an unallocated pixel */
  2527. + #endif
  2528.         int           d, k, mdist, close;
  2529.         unsigned long ri,gi,bi;
  2530.   
  2531. **************
  2532. *** 483,488
  2533.       }
  2534.       if (close<0) FatalError("This Can't Happen! (How reassuring.)");
  2535.       memcpy(&defs[i], &ctab[close], sizeof(XColor));
  2536.       cols[i] = defs[i].pixel;
  2537.       p3alloc++;
  2538.         }
  2539. --- 512,520 -----
  2540.       }
  2541.       if (close<0) FatalError("This Can't Happen! (How reassuring.)");
  2542.       memcpy(&defs[i], &ctab[close], sizeof(XColor));
  2543. + #ifdef VMS
  2544. +     colors[i] = defs[i].pixel;
  2545. + #else
  2546.       cols[i] = defs[i].pixel;
  2547.   #endif
  2548.       p3alloc++;
  2549. **************
  2550. *** 484,489
  2551.       if (close<0) FatalError("This Can't Happen! (How reassuring.)");
  2552.       memcpy(&defs[i], &ctab[close], sizeof(XColor));
  2553.       cols[i] = defs[i].pixel;
  2554.       p3alloc++;
  2555.         }
  2556.         
  2557. --- 516,522 -----
  2558.       colors[i] = defs[i].pixel;
  2559.   #else
  2560.       cols[i] = defs[i].pixel;
  2561. + #endif
  2562.       p3alloc++;
  2563.         }
  2564.         
  2565. **************
  2566. *** 497,502
  2567.       }
  2568.       if (close<0) FatalError("This Can't Happen! (How reassuring.)");
  2569.       memcpy(&defs[i], &defs[close], sizeof(XColor));
  2570.       cols[i] = defs[i].pixel;
  2571.         }
  2572.       }
  2573. --- 530,538 -----
  2574.       }
  2575.       if (close<0) FatalError("This Can't Happen! (How reassuring.)");
  2576.       memcpy(&defs[i], &defs[close], sizeof(XColor));
  2577. + #ifdef VMS
  2578. +     colors[i] = defs[i].pixel;
  2579. + #else
  2580.       cols[i] = defs[i].pixel;
  2581.   #endif
  2582.         }
  2583. **************
  2584. *** 498,503
  2585.       if (close<0) FatalError("This Can't Happen! (How reassuring.)");
  2586.       memcpy(&defs[i], &defs[close], sizeof(XColor));
  2587.       cols[i] = defs[i].pixel;
  2588.         }
  2589.       }
  2590.     }  /* THIRD PASS */
  2591. --- 534,540 -----
  2592.       colors[i] = defs[i].pixel;
  2593.   #else
  2594.       cols[i] = defs[i].pixel;
  2595. + #endif
  2596.         }
  2597.       }
  2598.     }  /* THIRD PASS */
  2599. **************
  2600. *** 538,543
  2601.   
  2602.     cmap = theCmap;
  2603.   
  2604.     for (i=0; i<numcols; i++) cols[i] = NOPIX;
  2605.   
  2606.     for (i=0; i<numcols && i<ncols; i++) {
  2607. --- 575,583 -----
  2608.   
  2609.     cmap = theCmap;
  2610.   
  2611. + #ifdef VMS
  2612. +   for (i=0; i<numcols; i++) colors[i] = NOPIX;
  2613. + #else
  2614.     for (i=0; i<numcols; i++) cols[i] = NOPIX;
  2615.   #endif
  2616.   
  2617. **************
  2618. *** 539,544
  2619.     cmap = theCmap;
  2620.   
  2621.     for (i=0; i<numcols; i++) cols[i] = NOPIX;
  2622.   
  2623.     for (i=0; i<numcols && i<ncols; i++) {
  2624.       unsigned long pmr[1], pix[1];
  2625. --- 579,585 -----
  2626.     for (i=0; i<numcols; i++) colors[i] = NOPIX;
  2627.   #else
  2628.     for (i=0; i<numcols; i++) cols[i] = NOPIX;
  2629. + #endif
  2630.   
  2631.     for (i=0; i<numcols && i<ncols; i++) {
  2632.       unsigned long pmr[1], pix[1];
  2633. **************
  2634. *** 543,548
  2635.     for (i=0; i<numcols && i<ncols; i++) {
  2636.       unsigned long pmr[1], pix[1];
  2637.       if (XAllocColorCells(theDisp, cmap, False, pmr, 0, pix, 1)) {
  2638.         defs[i].pixel = cols[i] = pix[0];
  2639.         defs[i].red   = r[i]<<8;
  2640.         defs[i].green = g[i]<<8;
  2641. --- 584,592 -----
  2642.     for (i=0; i<numcols && i<ncols; i++) {
  2643.       unsigned long pmr[1], pix[1];
  2644.       if (XAllocColorCells(theDisp, cmap, False, pmr, 0, pix, 1)) {
  2645. + #ifdef VMS
  2646. +       defs[i].pixel = colors[i] = pix[0];
  2647. + #else
  2648.         defs[i].pixel = cols[i] = pix[0];
  2649.   #endif
  2650.         defs[i].red   = r[i]<<8;
  2651. **************
  2652. *** 544,549
  2653.       unsigned long pmr[1], pix[1];
  2654.       if (XAllocColorCells(theDisp, cmap, False, pmr, 0, pix, 1)) {
  2655.         defs[i].pixel = cols[i] = pix[0];
  2656.         defs[i].red   = r[i]<<8;
  2657.         defs[i].green = g[i]<<8;
  2658.         defs[i].blue  = b[i]<<8;
  2659. --- 588,594 -----
  2660.         defs[i].pixel = colors[i] = pix[0];
  2661.   #else
  2662.         defs[i].pixel = cols[i] = pix[0];
  2663. + #endif
  2664.         defs[i].red   = r[i]<<8;
  2665.         defs[i].green = g[i]<<8;
  2666.         defs[i].blue  = b[i]<<8;
  2667. **************
  2668. *** 561,566
  2669.       i--;      /* redo the allocation request */
  2670.         }
  2671.   
  2672.         else cols[i] = NOPIX;
  2673.       }
  2674.     }  /* for (i=0; ... */
  2675. --- 606,614 -----
  2676.       i--;      /* redo the allocation request */
  2677.         }
  2678.   
  2679. + #ifdef VMS
  2680. +       else colors[i] = NOPIX;
  2681. + #else
  2682.         else cols[i] = NOPIX;
  2683.   #endif
  2684.       }
  2685. **************
  2686. *** 562,567
  2687.         }
  2688.   
  2689.         else cols[i] = NOPIX;
  2690.       }
  2691.     }  /* for (i=0; ... */
  2692.   
  2693. --- 610,616 -----
  2694.         else colors[i] = NOPIX;
  2695.   #else
  2696.         else cols[i] = NOPIX;
  2697. + #endif
  2698.       }
  2699.     }  /* for (i=0; ... */
  2700.   
  2701. **************
  2702. *** 585,590
  2703.         SetISTR(ISTR_COLOR,"Got %d out of %d colors.",  nfcols,numcols);
  2704.   
  2705.         for (i=0; i<numcols; i++)
  2706.       if (cols[i]==NOPIX) {  /* an unallocated pixel */
  2707.         int           k, d, mdist, close;
  2708.         unsigned long ri,gi,bi;
  2709. --- 634,642 -----
  2710.         SetISTR(ISTR_COLOR,"Got %d out of %d colors.",  nfcols,numcols);
  2711.   
  2712.         for (i=0; i<numcols; i++)
  2713. + #ifdef VMS
  2714. +     if (colors[i]==NOPIX) {  /* an unallocated pixel */
  2715. + #else
  2716.       if (cols[i]==NOPIX) {  /* an unallocated pixel */
  2717.   #endif
  2718.         int           k, d, mdist, close;
  2719. **************
  2720. *** 586,591
  2721.   
  2722.         for (i=0; i<numcols; i++)
  2723.       if (cols[i]==NOPIX) {  /* an unallocated pixel */
  2724.         int           k, d, mdist, close;
  2725.         unsigned long ri,gi,bi;
  2726.   
  2727. --- 638,644 -----
  2728.       if (colors[i]==NOPIX) {  /* an unallocated pixel */
  2729.   #else
  2730.       if (cols[i]==NOPIX) {  /* an unallocated pixel */
  2731. + #endif
  2732.         int           k, d, mdist, close;
  2733.         unsigned long ri,gi,bi;
  2734.   
  2735. **************
  2736. *** 600,605
  2737.         }
  2738.   
  2739.         if (close<0) FatalError("This Can't Happen! (How reassuring.)");
  2740.         cols[i] = defs[close].pixel;
  2741.       }
  2742.       }
  2743. --- 653,661 -----
  2744.         }
  2745.   
  2746.         if (close<0) FatalError("This Can't Happen! (How reassuring.)");
  2747. + #ifdef VMS
  2748. +       colors[i] = defs[close].pixel;
  2749. + #else
  2750.         cols[i] = defs[close].pixel;
  2751.   #endif
  2752.       }
  2753. **************
  2754. *** 601,606
  2755.   
  2756.         if (close<0) FatalError("This Can't Happen! (How reassuring.)");
  2757.         cols[i] = defs[close].pixel;
  2758.       }
  2759.       }
  2760.   
  2761. --- 657,663 -----
  2762.         colors[i] = defs[close].pixel;
  2763.   #else
  2764.         cols[i] = defs[close].pixel;
  2765. + #endif
  2766.       }
  2767.       }
  2768.   
  2769. **************
  2770. *** 1131,1136
  2771.         else {
  2772.       for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++,ip++) {
  2773.         if ((i&0x1ffff) == 0) WaitCursor();
  2774.         *ip = (byte) cols[*pp];
  2775.       }
  2776.         }
  2777. --- 1188,1196 -----
  2778.         else {
  2779.       for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++,ip++) {
  2780.         if ((i&0x1ffff) == 0) WaitCursor();
  2781. + #ifdef VMS
  2782. +       *ip = (byte) colors[*pp];
  2783. + #else
  2784.         *ip = (byte) cols[*pp];
  2785.   #endif
  2786.       }
  2787. **************
  2788. *** 1132,1137
  2789.       for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++,ip++) {
  2790.         if ((i&0x1ffff) == 0) WaitCursor();
  2791.         *ip = (byte) cols[*pp];
  2792.       }
  2793.         }
  2794.   
  2795. --- 1192,1198 -----
  2796.         *ip = (byte) colors[*pp];
  2797.   #else
  2798.         *ip = (byte) cols[*pp];
  2799. + #endif
  2800.       }
  2801.         }
  2802.   
  2803. **************
  2804. *** 1199,1204
  2805.         for (i=0, pp=epic, lip=imagedata; i<eHIGH; i++, lip+=bperline) {
  2806.           if ((i&127) == 0) WaitCursor();
  2807.           for (j=0, ip=lip, half=0; j<eWIDE; j++,pp++,half++) {
  2808.             if (half&1) { *ip = *ip + ((cols[*pp]&0x0f)<<4);  ip++; }
  2809.             else *ip = cols[*pp]&0x0f;
  2810.           }
  2811. --- 1260,1269 -----
  2812.         for (i=0, pp=epic, lip=imagedata; i<eHIGH; i++, lip+=bperline) {
  2813.           if ((i&127) == 0) WaitCursor();
  2814.           for (j=0, ip=lip, half=0; j<eWIDE; j++,pp++,half++) {
  2815. + #ifdef VMS
  2816. +           if (half&1) { *ip = *ip + ((colors[*pp]&0x0f)<<4);  ip++; }
  2817. +           else *ip = colors[*pp]&0x0f;
  2818. + #else
  2819.             if (half&1) { *ip = *ip + ((cols[*pp]&0x0f)<<4);  ip++; }
  2820.             else *ip = cols[*pp]&0x0f;
  2821.   #endif
  2822. **************
  2823. *** 1201,1206
  2824.           for (j=0, ip=lip, half=0; j<eWIDE; j++,pp++,half++) {
  2825.             if (half&1) { *ip = *ip + ((cols[*pp]&0x0f)<<4);  ip++; }
  2826.             else *ip = cols[*pp]&0x0f;
  2827.           }
  2828.         }
  2829.       }
  2830. --- 1266,1272 -----
  2831.   #else
  2832.             if (half&1) { *ip = *ip + ((cols[*pp]&0x0f)<<4);  ip++; }
  2833.             else *ip = cols[*pp]&0x0f;
  2834. + #endif
  2835.           }
  2836.         }
  2837.       }
  2838. **************
  2839. *** 1207,1212
  2840.       else if (theImage->bits_per_pixel == 8) {
  2841.         for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++,ip++) {
  2842.           if ((i&0x1ffff) == 0) WaitCursor();
  2843.           *ip = (byte) cols[*pp];
  2844.         }
  2845.       }
  2846. --- 1273,1281 -----
  2847.       else if (theImage->bits_per_pixel == 8) {
  2848.         for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++,ip++) {
  2849.           if ((i&0x1ffff) == 0) WaitCursor();
  2850. + #ifdef VMS
  2851. +         *ip = (byte) colors[*pp];
  2852. + #else
  2853.           *ip = (byte) cols[*pp];
  2854.   #endif
  2855.         }
  2856. **************
  2857. *** 1208,1213
  2858.         for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++,ip++) {
  2859.           if ((i&0x1ffff) == 0) WaitCursor();
  2860.           *ip = (byte) cols[*pp];
  2861.         }
  2862.       }
  2863.       else FatalError("This display's too bizarre.  Can't create XImage.");
  2864. --- 1277,1283 -----
  2865.           *ip = (byte) colors[*pp];
  2866.   #else
  2867.           *ip = (byte) cols[*pp];
  2868. + #endif
  2869.         }
  2870.       }
  2871.       else FatalError("This display's too bizarre.  Can't create XImage.");
  2872. **************
  2873. *** 1238,1243
  2874.         else {
  2875.       for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++,ip++) {
  2876.         if ((i&0x1ffff) == 0) WaitCursor();
  2877.         *ip = (byte) cols[*pp];
  2878.       }
  2879.         }
  2880. --- 1308,1316 -----
  2881.         else {
  2882.       for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++,ip++) {
  2883.         if ((i&0x1ffff) == 0) WaitCursor();
  2884. + #ifdef VMS
  2885. +       *ip = (byte) colors[*pp];
  2886. + #else
  2887.         *ip = (byte) cols[*pp];
  2888.   #endif
  2889.       }
  2890. **************
  2891. *** 1239,1244
  2892.       for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++,ip++) {
  2893.         if ((i&0x1ffff) == 0) WaitCursor();
  2894.         *ip = (byte) cols[*pp];
  2895.       }
  2896.         }
  2897.         
  2898. --- 1312,1318 -----
  2899.         *ip = (byte) colors[*pp];
  2900.   #else
  2901.         *ip = (byte) cols[*pp];
  2902. + #endif
  2903.       }
  2904.         }
  2905.         
  2906. **************
  2907. *** 1262,1267
  2908.       for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++) {
  2909.         if ((i&0x1ffff) == 0) WaitCursor();
  2910.         *ip++ = 0;
  2911.         *ip++ = (cols[*pp]>>16) & 0xff;
  2912.         *ip++ = (cols[*pp]>>8) & 0xff;
  2913.         *ip++ =  cols[*pp] & 0xff;
  2914. --- 1336,1346 -----
  2915.       for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++) {
  2916.         if ((i&0x1ffff) == 0) WaitCursor();
  2917.         *ip++ = 0;
  2918. + #ifdef VMS
  2919. +       *ip++ = (colors[*pp]>>16) & 0xff;
  2920. +       *ip++ = (colors[*pp]>>8) & 0xff;
  2921. +       *ip++ =  colors[*pp] & 0xff;
  2922. + #else
  2923.         *ip++ = (cols[*pp]>>16) & 0xff;
  2924.         *ip++ = (cols[*pp]>>8) & 0xff;
  2925.         *ip++ =  cols[*pp] & 0xff;
  2926. **************
  2927. *** 1265,1270
  2928.         *ip++ = (cols[*pp]>>16) & 0xff;
  2929.         *ip++ = (cols[*pp]>>8) & 0xff;
  2930.         *ip++ =  cols[*pp] & 0xff;
  2931.       }
  2932.         else 
  2933.       for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++) {
  2934. --- 1344,1350 -----
  2935.         *ip++ = (cols[*pp]>>16) & 0xff;
  2936.         *ip++ = (cols[*pp]>>8) & 0xff;
  2937.         *ip++ =  cols[*pp] & 0xff;
  2938. + #endif
  2939.       }
  2940.         else 
  2941.       for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++) {
  2942. **************
  2943. *** 1269,1274
  2944.         else 
  2945.       for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++) {
  2946.         if ((i&0x1ffff) == 0) WaitCursor();
  2947.         *ip++ =  cols[*pp] & 0xff;
  2948.         *ip++ = (cols[*pp]>>8) & 0xff;
  2949.         *ip++ = (cols[*pp]>>16) & 0xff;
  2950. --- 1349,1359 -----
  2951.         else 
  2952.       for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++) {
  2953.         if ((i&0x1ffff) == 0) WaitCursor();
  2954. + #ifdef VMS
  2955. +       *ip++ =  colors[*pp] & 0xff;
  2956. +       *ip++ = (colors[*pp]>>8) & 0xff;
  2957. +       *ip++ = (colors[*pp]>>16) & 0xff;
  2958. + #else
  2959.         *ip++ =  cols[*pp] & 0xff;
  2960.         *ip++ = (cols[*pp]>>8) & 0xff;
  2961.         *ip++ = (cols[*pp]>>16) & 0xff;
  2962. **************
  2963. *** 1272,1277
  2964.         *ip++ =  cols[*pp] & 0xff;
  2965.         *ip++ = (cols[*pp]>>8) & 0xff;
  2966.         *ip++ = (cols[*pp]>>16) & 0xff;
  2967.         *ip++ = 0;
  2968.       }
  2969.         }      
  2970. --- 1357,1363 -----
  2971.         *ip++ =  cols[*pp] & 0xff;
  2972.         *ip++ = (cols[*pp]>>8) & 0xff;
  2973.         *ip++ = (cols[*pp]>>16) & 0xff;
  2974. + #endif
  2975.         *ip++ = 0;
  2976.       }
  2977.         }      
  2978. **************
  2979. *** 1571,1576
  2980.   /*******/
  2981.   {
  2982.     long usec;
  2983.     struct itimerval it;
  2984.   
  2985.     if (!n) return;
  2986. --- 1657,1663 -----
  2987.   /*******/
  2988.   {
  2989.     long usec;
  2990. + #ifndef VMS
  2991.     struct itimerval it;
  2992.   #endif
  2993.   
  2994. **************
  2995. *** 1572,1577
  2996.   {
  2997.     long usec;
  2998.     struct itimerval it;
  2999.   
  3000.     if (!n) return;
  3001.     if (fishrunning) { PAUSE_SIG; return; }
  3002. --- 1659,1665 -----
  3003.     long usec;
  3004.   #ifndef VMS
  3005.     struct itimerval it;
  3006. + #endif
  3007.   
  3008.     if (!n) return;
  3009.     if (fishrunning) { PAUSE_SIG; return; }
  3010. **************
  3011. *** 1591,1596
  3012.     return;
  3013.   #endif
  3014.   
  3015.     usec = (long) n * 1000;
  3016.     
  3017.     memset(&it, 0, sizeof(it));
  3018. --- 1679,1685 -----
  3019.     return;
  3020.   #endif
  3021.   
  3022. + #ifndef VMS
  3023.     usec = (long) n * 1000;
  3024.     
  3025.     memset(&it, 0, sizeof(it));
  3026. **************
  3027. *** 1611,1616
  3028.   
  3029.     RELEASE_SIG;                   /* turn ALRM blocking off */
  3030.     signal(SIGALRM,SIG_DFL);
  3031.   }
  3032.   
  3033.   
  3034. --- 1700,1704 -----
  3035.   
  3036.     RELEASE_SIG;                   /* turn ALRM blocking off */
  3037.     signal(SIGALRM,SIG_DFL);
  3038. + #endif  /* VMS */
  3039.   }
  3040. **************
  3041. *** 1612,1620
  3042.     RELEASE_SIG;                   /* turn ALRM blocking off */
  3043.     signal(SIGALRM,SIG_DFL);
  3044.   }
  3045. --- 1702,1704 -----
  3046.     signal(SIGALRM,SIG_DFL);
  3047.   #endif  /* VMS */
  3048.   }
  3049.